Amesos Package Browser (Single Doxygen Collection)
Development
src
SuiteSparse
KLU
Include
amesos_klu_version.h
Go to the documentation of this file.
1
#ifndef AMESOS_KLU_VERSION_H
2
#define AMESOS_KLU_VERSION_H
3
4
#ifdef DLONG
5
#define Int UF_long
6
#define Int_id UF_long_id
7
#define Int_MAX UF_long_max
8
#else
9
#define Int int
10
#define Int_id "%d"
11
#define Int_MAX INT_MAX
12
#endif
13
14
#define NPRINT
15
16
#define BYTES(type,n) (sizeof (type) * (n))
17
#define CEILING(b,u) (((b)+(u)-1) / (u))
18
#define UNITS(type,n) (CEILING (BYTES (type,n), sizeof (Unit)))
19
#define DUNITS(type,n) (ceil (BYTES (type, (double) n) / sizeof (Unit)))
20
21
#define GET_I_POINTER(LU, Xip, Xi, k) \
22
{ \
23
Xi = (Int *) (LU + Xip [k]) ; \
24
}
25
26
#define GET_X_POINTER(LU, Xip, Xlen, Xx, k) \
27
{ \
28
Xx = (Entry *) (LU + Xip [k] + UNITS (Int, Xlen [k])) ; \
29
}
30
31
#define GET_POINTER(LU, Xip, Xlen, Xi, Xx, k, xlen) \
32
{ \
33
Unit *xp = LU + Xip [k] ; \
34
xlen = Xlen [k] ; \
35
Xi = (Int *) xp ; \
36
Xx = (Entry *) (xp + UNITS (Int, xlen)) ; \
37
}
38
39
/* function names */
40
#ifdef COMPLEX
41
42
#ifdef DLONG
43
44
#define KLU_scale amesos_klu_zl_scale
45
#define KLU_solve amesos_klu_zl_solve
46
#define KLU_tsolve amesos_klu_zl_tsolve
47
#define KLU_free_numeric amesos_klu_zl_free_numeric
48
#define KLU_factor amesos_klu_zl_factor
49
#define KLU_refactor amesos_klu_zl_refactor
50
#define KLU_kernel_factor amesos_klu_zl_kernel_factor
51
#define KLU_lsolve amesos_klu_zl_lsolve
52
#define KLU_ltsolve amesos_klu_zl_ltsolve
53
#define KLU_usolve amesos_klu_zl_usolve
54
#define KLU_utsolve amesos_klu_zl_utsolve
55
#define KLU_kernel amesos_klu_zl_kernel
56
#define KLU_valid amesos_klu_zl_valid
57
#define KLU_valid_LU amesos_klu_zl_valid_LU
58
#define KLU_sort amesos_klu_zl_sort
59
#define KLU_rgrowth amesos_klu_zl_rgrowth
60
#define KLU_rcond amesos_klu_zl_rcond
61
#define KLU_extract amesos_klu_zl_extract
62
#define KLU_condest amesos_klu_zl_condest
63
#define KLU_flops amesos_klu_zl_flops
64
65
#else
66
67
#define KLU_scale amesos_klu_z_scale
68
#define KLU_solve amesos_klu_z_solve
69
#define KLU_tsolve amesos_klu_z_tsolve
70
#define KLU_free_numeric amesos_klu_z_free_numeric
71
#define KLU_factor amesos_klu_z_factor
72
#define KLU_refactor amesos_klu_z_refactor
73
#define KLU_kernel_factor amesos_klu_z_kernel_factor
74
#define KLU_lsolve amesos_klu_z_lsolve
75
#define KLU_ltsolve amesos_klu_z_ltsolve
76
#define KLU_usolve amesos_klu_z_usolve
77
#define KLU_utsolve amesos_klu_z_utsolve
78
#define KLU_kernel amesos_klu_z_kernel
79
#define KLU_valid amesos_klu_z_valid
80
#define KLU_valid_LU amesos_klu_z_valid_LU
81
#define KLU_sort amesos_klu_z_sort
82
#define KLU_rgrowth amesos_klu_z_rgrowth
83
#define KLU_rcond amesos_klu_z_rcond
84
#define KLU_extract amesos_klu_z_extract
85
#define KLU_condest amesos_klu_z_condest
86
#define KLU_flops amesos_klu_z_flops
87
88
#endif
89
90
#else
91
92
#ifdef DLONG
93
94
#define KLU_scale amesos_klu_l_scale
95
#define KLU_solve amesos_klu_l_solve
96
#define KLU_tsolve amesos_klu_l_tsolve
97
#define KLU_free_numeric amesos_klu_l_free_numeric
98
#define KLU_factor amesos_klu_l_factor
99
#define KLU_refactor amesos_klu_l_refactor
100
#define KLU_kernel_factor amesos_klu_l_kernel_factor
101
#define KLU_lsolve amesos_klu_l_lsolve
102
#define KLU_ltsolve amesos_klu_l_ltsolve
103
#define KLU_usolve amesos_klu_l_usolve
104
#define KLU_utsolve amesos_klu_l_utsolve
105
#define KLU_kernel amesos_klu_l_kernel
106
#define KLU_valid amesos_klu_l_valid
107
#define KLU_valid_LU amesos_klu_l_valid_LU
108
#define KLU_sort amesos_klu_l_sort
109
#define KLU_rgrowth amesos_klu_l_rgrowth
110
#define KLU_rcond amesos_klu_l_rcond
111
#define KLU_extract amesos_klu_l_extract
112
#define KLU_condest amesos_klu_l_condest
113
#define KLU_flops amesos_klu_l_flops
114
115
#else
116
117
#define KLU_scale amesos_klu_scale
118
#define KLU_solve amesos_klu_solve
119
#define KLU_tsolve amesos_klu_tsolve
120
#define KLU_free_numeric amesos_klu_free_numeric
121
#define KLU_factor amesos_klu_factor
122
#define KLU_refactor amesos_klu_refactor
123
#define KLU_kernel_factor amesos_klu_kernel_factor
124
#define KLU_lsolve amesos_klu_lsolve
125
#define KLU_ltsolve amesos_klu_ltsolve
126
#define KLU_usolve amesos_klu_usolve
127
#define KLU_utsolve amesos_klu_utsolve
128
#define KLU_kernel amesos_klu_kernel
129
#define KLU_valid amesos_klu_valid
130
#define KLU_valid_LU amesos_klu_valid_LU
131
#define KLU_sort amesos_klu_sort
132
#define KLU_rgrowth amesos_klu_rgrowth
133
#define KLU_rcond amesos_klu_rcond
134
#define KLU_extract amesos_klu_extract
135
#define KLU_condest amesos_klu_condest
136
#define KLU_flops amesos_klu_flops
137
138
#endif
139
140
#endif
141
142
143
#ifdef DLONG
144
145
#define KLU_analyze amesos_klu_l_analyze
146
#define KLU_analyze_given amesos_klu_l_analyze_given
147
#define KLU_alloc_symbolic amesos_klu_l_alloc_symbolic
148
#define KLU_free_symbolic amesos_klu_l_free_symbolic
149
#define KLU_defaults amesos_klu_l_defaults
150
#define KLU_free amesos_klu_l_free
151
#define KLU_malloc amesos_klu_l_malloc
152
#define KLU_realloc amesos_klu_l_realloc
153
#define KLU_add_size_t amesos_klu_l_add_size_t
154
#define KLU_mult_size_t amesos_klu_l_mult_size_t
155
156
#define KLU_symbolic klu_l_symbolic
157
#define KLU_numeric klu_l_numeric
158
#define KLU_common klu_l_common
159
160
#define BTF_order amesos_btf_l_order
161
#define BTF_strongcomp amesos_btf_l_strongcomp
162
163
#define AMD_order amesos_amd_l_order
164
#define COLAMD amesos_colamd_l
165
#define COLAMD_recommended amesos_colamd_l_recommended
166
167
#else
168
169
#define KLU_analyze amesos_klu_analyze
170
#define KLU_analyze_given amesos_klu_analyze_given
171
#define KLU_alloc_symbolic amesos_klu_alloc_symbolic
172
#define KLU_free_symbolic amesos_klu_free_symbolic
173
#define KLU_defaults amesos_klu_defaults
174
#define KLU_free amesos_klu_free
175
#define KLU_malloc amesos_klu_malloc
176
#define KLU_realloc amesos_klu_realloc
177
#define KLU_add_size_t amesos_klu_add_size_t
178
#define KLU_mult_size_t amesos_klu_mult_size_t
179
180
#define KLU_symbolic klu_symbolic
181
#define KLU_numeric klu_numeric
182
#define KLU_common klu_common
183
184
#define BTF_order amesos_btf_order
185
#define BTF_strongcomp amesos_btf_strongcomp
186
187
#define AMD_order amesos_amd_order
188
#define COLAMD amesos_colamd
189
#define COLAMD_recommended amesos_colamd_recommended
190
191
#endif
192
193
194
/* -------------------------------------------------------------------------- */
195
/* Numerical relop macros for correctly handling the NaN case */
196
/* -------------------------------------------------------------------------- */
197
198
/*
199
SCALAR_IS_NAN(x):
200
True if x is NaN. False otherwise. The commonly-existing isnan(x)
201
function could be used, but it's not in Kernighan & Ritchie 2nd edition
202
(ANSI C). It may appear in <math.h>, but I'm not certain about
203
portability. The expression x != x is true if and only if x is NaN,
204
according to the IEEE 754 floating-point standard.
205
206
SCALAR_IS_ZERO(x):
207
True if x is zero. False if x is nonzero, NaN, or +/- Inf.
208
This is (x == 0) if the compiler is IEEE 754 compliant.
209
210
SCALAR_IS_NONZERO(x):
211
True if x is nonzero, NaN, or +/- Inf. False if x zero.
212
This is (x != 0) if the compiler is IEEE 754 compliant.
213
214
SCALAR_IS_LTZERO(x):
215
True if x is < zero or -Inf. False if x is >= 0, NaN, or +Inf.
216
This is (x < 0) if the compiler is IEEE 754 compliant.
217
*/
218
219
/* These all work properly, according to the IEEE 754 standard ... except on */
220
/* a PC with windows. Works fine in Linux on the same PC... */
221
#define SCALAR_IS_NAN(x) ((x) != (x))
222
#define SCALAR_IS_ZERO(x) ((x) == 0.)
223
#define SCALAR_IS_NONZERO(x) ((x) != 0.)
224
#define SCALAR_IS_LTZERO(x) ((x) < 0.)
225
226
227
/* scalar absolute value macro. If x is NaN, the result is NaN: */
228
#define SCALAR_ABS(x) ((SCALAR_IS_LTZERO (x)) ? -(x) : (x))
229
230
/* print a scalar (avoid printing "-0" for negative zero). */
231
#ifdef NPRINT
232
#define PRINT_SCALAR(a)
233
#else
234
#define PRINT_SCALAR(a) \
235
{ \
236
if (SCALAR_IS_NONZERO (a)) \
237
{ \
238
PRINTF ((" (%g)", (a))) ; \
239
} \
240
else \
241
{ \
242
PRINTF ((" (0)")) ; \
243
} \
244
}
245
#endif
246
247
/* -------------------------------------------------------------------------- */
248
/* Real floating-point arithmetic */
249
/* -------------------------------------------------------------------------- */
250
251
#ifndef COMPLEX
252
253
typedef
double
Unit
;
254
#define Entry double
255
256
#define SPLIT(s) (1)
257
#define REAL(c) (c)
258
#define IMAG(c) (0.)
259
#define ASSIGN(c,s1,s2,p,split) { (c) = (s1)[p] ; }
260
#define CLEAR(c) { (c) = 0. ; }
261
#define CLEAR_AND_INCREMENT(p) { *p++ = 0. ; }
262
#define IS_NAN(a) SCALAR_IS_NAN (a)
263
#define IS_ZERO(a) SCALAR_IS_ZERO (a)
264
#define IS_NONZERO(a) SCALAR_IS_NONZERO (a)
265
#define SCALE_DIV(c,s) { (c) /= (s) ; }
266
#define SCALE_DIV_ASSIGN(a,c,s) { a = c / s ; }
267
#define SCALE(c,s) { (c) *= (s) ; }
268
#define ASSEMBLE(c,a) { (c) += (a) ; }
269
#define ASSEMBLE_AND_INCREMENT(c,p) { (c) += *p++ ; }
270
#define DECREMENT(c,a) { (c) -= (a) ; }
271
#define MULT(c,a,b) { (c) = (a) * (b) ; }
272
#define MULT_CONJ(c,a,b) { (c) = (a) * (b) ; }
273
#define MULT_SUB(c,a,b) { (c) -= (a) * (b) ; }
274
#define MULT_SUB_CONJ(c,a,b) { (c) -= (a) * (b) ; }
275
#define DIV(c,a,b) { (c) = (a) / (b) ; }
276
#define RECIPROCAL(c) { (c) = 1.0 / (c) ; }
277
#define DIV_CONJ(c,a,b) { (c) = (a) / (b) ; }
278
#define APPROX_ABS(s,a) { (s) = SCALAR_ABS (a) ; }
279
#define ABS(s,a) { (s) = SCALAR_ABS (a) ; }
280
#define PRINT_ENTRY(a) PRINT_SCALAR (a)
281
#define CONJ(a,x) a = x
282
283
/* for flop counts */
284
#define MULTSUB_FLOPS 2.
/* c -= a*b */
285
#define DIV_FLOPS 1.
/* c = a/b */
286
#define ABS_FLOPS 0.
/* c = abs (a) */
287
#define ASSEMBLE_FLOPS 1.
/* c += a */
288
#define DECREMENT_FLOPS 1.
/* c -= a */
289
#define MULT_FLOPS 1.
/* c = a*b */
290
#define SCALE_FLOPS 1.
/* c = a/s */
291
292
#else
293
294
/* -------------------------------------------------------------------------- */
295
/* Complex floating-point arithmetic */
296
/* -------------------------------------------------------------------------- */
297
298
/*
299
Note: An alternative to this Double_Complex type would be to use a
300
struct { double r ; double i ; }. The problem with that method
301
(used by the Sun Performance Library, for example) is that ANSI C provides
302
no guarantee about the layout of a struct. It is possible that the sizeof
303
the struct above would be greater than 2 * sizeof (double). This would
304
mean that the complex BLAS could not be used. The method used here avoids
305
that possibility. ANSI C *does* guarantee that an array of structs has
306
the same size as n times the size of one struct.
307
308
The ANSI C99 version of the C language includes a "double _Complex" type.
309
It should be possible in that case to do the following:
310
311
#define Entry double _Complex
312
313
and remove the Double_Complex struct. The macros, below, could then be
314
replaced with instrinsic operators. Note that the #define Real and
315
#define Imag should also be removed (they only appear in this file).
316
317
For the MULT, MULT_SUB, MULT_SUB_CONJ, and MULT_CONJ macros,
318
the output argument c cannot be the same as any input argument.
319
320
*/
321
322
typedef
struct
323
{
324
double
component [2] ;
/* real and imaginary parts */
325
326
} Double_Complex ;
327
328
typedef
Double_Complex
Unit
;
329
#define Entry Double_Complex
330
#define Real component [0]
331
#define Imag component [1]
332
333
/* for flop counts */
334
#define MULTSUB_FLOPS 8.
/* c -= a*b */
335
#define DIV_FLOPS 9.
/* c = a/b */
336
#define ABS_FLOPS 6.
/* c = abs (a), count sqrt as one flop */
337
#define ASSEMBLE_FLOPS 2.
/* c += a */
338
#define DECREMENT_FLOPS 2.
/* c -= a */
339
#define MULT_FLOPS 6.
/* c = a*b */
340
#define SCALE_FLOPS 2.
/* c = a/s or c = a*s */
341
342
/* -------------------------------------------------------------------------- */
343
344
/* real part of c */
345
#define REAL(c) ((c).Real)
346
347
/* -------------------------------------------------------------------------- */
348
349
/* imag part of c */
350
#define IMAG(c) ((c).Imag)
351
352
/* -------------------------------------------------------------------------- */
353
354
/* Return TRUE if a complex number is in split form, FALSE if in packed form */
355
#define SPLIT(sz) ((sz) != (double *) NULL)
356
357
/* c = (s1) + (s2)*i, if s2 is null, then X is in "packed" format (compatible
358
* with Entry and ANSI C99 double _Complex type). */
359
/*#define ASSIGN(c,s1,s2,p,split) \
360
{ \
361
if (split) \
362
{ \
363
(c).Real = (s1)[p] ; \
364
(c).Imag = (s2)[p] ; \
365
} \
366
else \
367
{ \
368
(c) = ((Entry *)(s1))[p] ; \
369
} \
370
}*/
371
372
/* -------------------------------------------------------------------------- */
373
#define CONJ(a, x) \
374
{ \
375
a.Real = x.Real ; \
376
a.Imag = -x.Imag ; \
377
}
378
379
/* c = 0 */
380
#define CLEAR(c) \
381
{ \
382
(c).Real = 0. ; \
383
(c).Imag = 0. ; \
384
}
385
386
/* -------------------------------------------------------------------------- */
387
388
/* *p++ = 0 */
389
#define CLEAR_AND_INCREMENT(p) \
390
{ \
391
p->Real = 0. ; \
392
p->Imag = 0. ; \
393
p++ ; \
394
}
395
396
/* -------------------------------------------------------------------------- */
397
398
/* True if a == 0 */
399
#define IS_ZERO(a) \
400
(SCALAR_IS_ZERO ((a).Real) && SCALAR_IS_ZERO ((a).Imag))
401
402
/* -------------------------------------------------------------------------- */
403
404
/* True if a is NaN */
405
#define IS_NAN(a) \
406
(SCALAR_IS_NAN ((a).Real) || SCALAR_IS_NAN ((a).Imag))
407
408
/* -------------------------------------------------------------------------- */
409
410
/* True if a != 0 */
411
#define IS_NONZERO(a) \
412
(SCALAR_IS_NONZERO ((a).Real) || SCALAR_IS_NONZERO ((a).Imag))
413
414
/* -------------------------------------------------------------------------- */
415
416
/* a = c/s */
417
#define SCALE_DIV_ASSIGN(a,c,s) \
418
{ \
419
a.Real = c.Real / s ; \
420
a.Imag = c.Imag / s ; \
421
}
422
423
/* c /= s */
424
#define SCALE_DIV(c,s) \
425
{ \
426
(c).Real /= (s) ; \
427
(c).Imag /= (s) ; \
428
}
429
430
/* -------------------------------------------------------------------------- */
431
432
/* c *= s */
433
#define SCALE(c,s) \
434
{ \
435
(c).Real *= (s) ; \
436
(c).Imag *= (s) ; \
437
}
438
439
/* -------------------------------------------------------------------------- */
440
441
/* c += a */
442
#define ASSEMBLE(c,a) \
443
{ \
444
(c).Real += (a).Real ; \
445
(c).Imag += (a).Imag ; \
446
}
447
448
/* -------------------------------------------------------------------------- */
449
450
/* c += *p++ */
451
#define ASSEMBLE_AND_INCREMENT(c,p) \
452
{ \
453
(c).Real += p->Real ; \
454
(c).Imag += p->Imag ; \
455
p++ ; \
456
}
457
458
/* -------------------------------------------------------------------------- */
459
460
/* c -= a */
461
#define DECREMENT(c,a) \
462
{ \
463
(c).Real -= (a).Real ; \
464
(c).Imag -= (a).Imag ; \
465
}
466
467
/* -------------------------------------------------------------------------- */
468
469
/* c = a*b, assert because c cannot be the same as a or b */
470
#define MULT(c,a,b) \
471
{ \
472
ASSERT (&(c) != &(a) && &(c) != &(b)) ; \
473
(c).Real = (a).Real * (b).Real - (a).Imag * (b).Imag ; \
474
(c).Imag = (a).Imag * (b).Real + (a).Real * (b).Imag ; \
475
}
476
477
/* -------------------------------------------------------------------------- */
478
479
/* c = a*conjugate(b), assert because c cannot be the same as a or b */
480
#define MULT_CONJ(c,a,b) \
481
{ \
482
ASSERT (&(c) != &(a) && &(c) != &(b)) ; \
483
(c).Real = (a).Real * (b).Real + (a).Imag * (b).Imag ; \
484
(c).Imag = (a).Imag * (b).Real - (a).Real * (b).Imag ; \
485
}
486
487
/* -------------------------------------------------------------------------- */
488
489
/* c -= a*b, assert because c cannot be the same as a or b */
490
#define MULT_SUB(c,a,b) \
491
{ \
492
ASSERT (&(c) != &(a) && &(c) != &(b)) ; \
493
(c).Real -= (a).Real * (b).Real - (a).Imag * (b).Imag ; \
494
(c).Imag -= (a).Imag * (b).Real + (a).Real * (b).Imag ; \
495
}
496
497
/* -------------------------------------------------------------------------- */
498
499
/* c -= a*conjugate(b), assert because c cannot be the same as a or b */
500
#define MULT_SUB_CONJ(c,a,b) \
501
{ \
502
ASSERT (&(c) != &(a) && &(c) != &(b)) ; \
503
(c).Real -= (a).Real * (b).Real + (a).Imag * (b).Imag ; \
504
(c).Imag -= (a).Imag * (b).Real - (a).Real * (b).Imag ; \
505
}
506
507
/* -------------------------------------------------------------------------- */
508
509
/* c = a/b, be careful to avoid underflow and overflow */
510
#ifdef MATHWORKS
511
#define DIV(c,a,b) \
512
{ \
513
(void) utDivideComplex ((a).Real, (a).Imag, (b).Real, (b).Imag, \
514
&((c).Real), &((c).Imag)) ; \
515
}
516
#else
517
/* This uses ACM Algo 116, by R. L. Smith, 1962. */
518
/* c can be the same variable as a or b. */
519
/* Ignore NaN case for double relop br>=bi. */
520
#define DIV(c,a,b) \
521
{ \
522
double r, den, ar, ai, br, bi ; \
523
br = (b).Real ; \
524
bi = (b).Imag ; \
525
ar = (a).Real ; \
526
ai = (a).Imag ; \
527
if (SCALAR_ABS (br) >= SCALAR_ABS (bi)) \
528
{ \
529
r = bi / br ; \
530
den = br + r * bi ; \
531
(c).Real = (ar + ai * r) / den ; \
532
(c).Imag = (ai - ar * r) / den ; \
533
} \
534
else \
535
{ \
536
r = br / bi ; \
537
den = r * br + bi ; \
538
(c).Real = (ar * r + ai) / den ; \
539
(c).Imag = (ai * r - ar) / den ; \
540
} \
541
}
542
#endif
543
544
/* -------------------------------------------------------------------------- */
545
546
/* c = 1/c, be careful to avoid underflow and overflow */
547
/* Not used if MATHWORKS is defined. */
548
/* This uses ACM Algo 116, by R. L. Smith, 1962. */
549
/* Ignore NaN case for double relop cr>=ci. */
550
#define RECIPROCAL(c) \
551
{ \
552
double r, den, cr, ci ; \
553
cr = (c).Real ; \
554
ci = (c).Imag ; \
555
if (SCALAR_ABS (cr) >= SCALAR_ABS (ci)) \
556
{ \
557
r = ci / cr ; \
558
den = cr + r * ci ; \
559
(c).Real = 1.0 / den ; \
560
(c).Imag = - r / den ; \
561
} \
562
else \
563
{ \
564
r = cr / ci ; \
565
den = r * cr + ci ; \
566
(c).Real = r / den ; \
567
(c).Imag = - 1.0 / den ; \
568
} \
569
}
570
571
572
/* -------------------------------------------------------------------------- */
573
574
/* c = a/conjugate(b), be careful to avoid underflow and overflow */
575
#ifdef MATHWORKS
576
#define DIV_CONJ(c,a,b) \
577
{ \
578
(void) utDivideComplex ((a).Real, (a).Imag, (b).Real, (-(b).Imag), \
579
&((c).Real), &((c).Imag)) ; \
580
}
581
#else
582
/* This uses ACM Algo 116, by R. L. Smith, 1962. */
583
/* c can be the same variable as a or b. */
584
/* Ignore NaN case for double relop br>=bi. */
585
#define DIV_CONJ(c,a,b) \
586
{ \
587
double r, den, ar, ai, br, bi ; \
588
br = (b).Real ; \
589
bi = (b).Imag ; \
590
ar = (a).Real ; \
591
ai = (a).Imag ; \
592
if (SCALAR_ABS (br) >= SCALAR_ABS (bi)) \
593
{ \
594
r = (-bi) / br ; \
595
den = br - r * bi ; \
596
(c).Real = (ar + ai * r) / den ; \
597
(c).Imag = (ai - ar * r) / den ; \
598
} \
599
else \
600
{ \
601
r = br / (-bi) ; \
602
den = r * br - bi; \
603
(c).Real = (ar * r + ai) / den ; \
604
(c).Imag = (ai * r - ar) / den ; \
605
} \
606
}
607
#endif
608
609
/* -------------------------------------------------------------------------- */
610
611
/* approximate absolute value, s = |r|+|i| */
612
#define APPROX_ABS(s,a) \
613
{ \
614
(s) = SCALAR_ABS ((a).Real) + SCALAR_ABS ((a).Imag) ; \
615
}
616
617
/* -------------------------------------------------------------------------- */
618
619
/* exact absolute value, s = sqrt (a.real^2 + amag^2) */
620
#ifdef MATHWORKS
621
#define ABS(s,a) \
622
{ \
623
(s) = utFdlibm_hypot ((a).Real, (a).Imag) ; \
624
}
625
#else
626
/* Ignore NaN case for the double relops ar>=ai and ar+ai==ar. */
627
#define ABS(s,a) \
628
{ \
629
double r, ar, ai ; \
630
ar = SCALAR_ABS ((a).Real) ; \
631
ai = SCALAR_ABS ((a).Imag) ; \
632
if (ar >= ai) \
633
{ \
634
if (ar + ai == ar) \
635
{ \
636
(s) = ar ; \
637
} \
638
else \
639
{ \
640
r = ai / ar ; \
641
(s) = ar * sqrt (1.0 + r*r) ; \
642
} \
643
} \
644
else \
645
{ \
646
if (ai + ar == ai) \
647
{ \
648
(s) = ai ; \
649
} \
650
else \
651
{ \
652
r = ar / ai ; \
653
(s) = ai * sqrt (1.0 + r*r) ; \
654
} \
655
} \
656
}
657
#endif
658
659
/* -------------------------------------------------------------------------- */
660
661
/* print an entry (avoid printing "-0" for negative zero). */
662
#ifdef NPRINT
663
#define PRINT_ENTRY(a)
664
#else
665
#define PRINT_ENTRY(a) \
666
{ \
667
if (SCALAR_IS_NONZERO ((a).Real)) \
668
{ \
669
PRINTF ((" (%g", (a).Real)) ; \
670
} \
671
else \
672
{ \
673
PRINTF ((" (0")) ; \
674
} \
675
if (SCALAR_IS_LTZERO ((a).Imag)) \
676
{ \
677
PRINTF ((" - %gi)", -(a).Imag)) ; \
678
} \
679
else if (SCALAR_IS_ZERO ((a).Imag)) \
680
{ \
681
PRINTF ((" + 0i)")) ; \
682
} \
683
else \
684
{ \
685
PRINTF ((" + %gi)", (a).Imag)) ; \
686
} \
687
}
688
#endif
689
690
/* -------------------------------------------------------------------------- */
691
692
#endif
/* #ifndef COMPLEX */
693
694
#endif
Unit
double Unit
Definition:
amesos_klu_version.h:253
Generated by
1.8.14