1 |
|
|
/* |
2 |
|
|
Teem: Tools to process and visualize scientific data and images . |
3 |
|
|
Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago |
4 |
|
|
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann |
5 |
|
|
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah |
6 |
|
|
|
7 |
|
|
This library is free software; you can redistribute it and/or |
8 |
|
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
|
(LGPL) as published by the Free Software Foundation; either |
10 |
|
|
version 2.1 of the License, or (at your option) any later version. |
11 |
|
|
The terms of redistributing and/or modifying this software also |
12 |
|
|
include exceptions to the LGPL that facilitate static linking. |
13 |
|
|
|
14 |
|
|
This library is distributed in the hope that it will be useful, |
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 |
|
|
Lesser General Public License for more details. |
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License |
20 |
|
|
along with this library; if not, write to Free Software Foundation, Inc., |
21 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "ell.h" |
26 |
|
|
|
27 |
|
|
/* |
28 |
|
|
** we use the name ellPresent (even though ell_present would be |
29 |
|
|
** properly consistent with the ell library name convention) because |
30 |
|
|
** we want to facilitate systematic testing of all libraries |
31 |
|
|
*/ |
32 |
|
|
const int |
33 |
|
|
ellPresent = 42; |
34 |
|
|
|
35 |
|
|
const char * |
36 |
|
|
ell_biff_key = "ell"; |
37 |
|
|
|
38 |
|
|
/* |
39 |
|
|
******** ell_debug |
40 |
|
|
** |
41 |
|
|
** some functions may use this value to control printing of |
42 |
|
|
** verbose debugging information |
43 |
|
|
*/ |
44 |
|
|
int ell_debug = 0; |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
const char * |
48 |
|
|
_ell_quadratic_root_str[] = { |
49 |
|
|
"(unknown ell_quadratic_root)", |
50 |
|
|
"two", |
51 |
|
|
"double", |
52 |
|
|
"complex" |
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
const char * |
56 |
|
|
_ell_quadratic_root_desc[] = { |
57 |
|
|
"(unknown ell_quadratic_root)", |
58 |
|
|
"two distinct roots", |
59 |
|
|
"one double root", |
60 |
|
|
"complex conjugate roots", |
61 |
|
|
}; |
62 |
|
|
|
63 |
|
|
airEnum |
64 |
|
|
_ell_quadratic_root = { |
65 |
|
|
"quadratic root solutions", |
66 |
|
|
ELL_QUADRATIC_ROOT_MAX, |
67 |
|
|
_ell_quadratic_root_str, NULL, |
68 |
|
|
_ell_quadratic_root_desc, |
69 |
|
|
NULL, NULL, |
70 |
|
|
AIR_FALSE |
71 |
|
|
}; |
72 |
|
|
const airEnum *const |
73 |
|
|
ell_quadratic_root = &_ell_quadratic_root; |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
const char * |
77 |
|
|
_ell_cubic_root_str[] = { |
78 |
|
|
"(unknown ell_cubic_root)", |
79 |
|
|
"single", |
80 |
|
|
"triple", |
81 |
|
|
"single and double", |
82 |
|
|
"three distinct" |
83 |
|
|
}; |
84 |
|
|
|
85 |
|
|
const char * |
86 |
|
|
_ell_cubic_root_desc[] = { |
87 |
|
|
"(unknown ell_cubic_root)", |
88 |
|
|
"one single root", |
89 |
|
|
"one triple root", |
90 |
|
|
"a single and a double root", |
91 |
|
|
"three distinct roots" |
92 |
|
|
}; |
93 |
|
|
|
94 |
|
|
airEnum |
95 |
|
|
_ell_cubic_root = { |
96 |
|
|
"cubic root solutions", |
97 |
|
|
ELL_CUBIC_ROOT_MAX, |
98 |
|
|
_ell_cubic_root_str, NULL, |
99 |
|
|
_ell_cubic_root_desc, |
100 |
|
|
NULL, NULL, |
101 |
|
|
AIR_FALSE |
102 |
|
|
}; |
103 |
|
|
const airEnum *const |
104 |
|
|
ell_cubic_root = &_ell_cubic_root; |
105 |
|
|
|
106 |
|
|
|
107 |
|
|
void |
108 |
|
|
ell_3m_print_f(FILE *f, const float s[9]) { |
109 |
|
|
|
110 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f\n", |
111 |
|
|
s[0], s[1], s[2]); |
112 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f\n", |
113 |
|
|
s[3], s[4], s[5]); |
114 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f\n", |
115 |
|
|
s[6], s[7], s[8]); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
void |
119 |
|
|
ell_3v_print_f(FILE *f, const float s[3]) { |
120 |
|
|
|
121 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f\n", |
122 |
|
|
s[0], s[1], s[2]); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
void |
126 |
|
|
ell_3m_print_d(FILE *f, const double s[9]) { |
127 |
|
|
|
128 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f\n", |
129 |
|
|
s[0], s[1], s[2]); |
130 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f\n", |
131 |
|
|
s[3], s[4], s[5]); |
132 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f\n", |
133 |
|
|
s[6], s[7], s[8]); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
void |
137 |
|
|
ell_3v_print_d(FILE *f, const double s[3]) { |
138 |
|
|
|
139 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f\n", |
140 |
|
|
s[0], s[1], s[2]); |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
void |
144 |
|
|
ell_4m_print_f(FILE *f, const float s[16]) { |
145 |
|
|
|
146 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f % 15.7f\n", |
147 |
|
|
s[ 0], s[ 1], s[ 2], s[ 3]); |
148 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f % 15.7f\n", |
149 |
|
|
s[ 4], s[ 5], s[ 6], s[ 7]); |
150 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f % 15.7f\n", |
151 |
|
|
s[ 8], s[ 9], s[10], s[11]); |
152 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f % 15.7f\n", |
153 |
|
|
s[12], s[13], s[14], s[15]); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
|
void |
157 |
|
|
ell_4v_print_f(FILE *f, const float s[4]) { |
158 |
|
|
|
159 |
|
|
fprintf(f, "% 15.7f % 15.7f % 15.7f % 15.7f\n", |
160 |
|
|
s[0], s[1], s[2], s[3]); |
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
void |
164 |
|
|
ell_4m_print_d(FILE *f, const double s[16]) { |
165 |
|
|
|
166 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f % 31.15f\n", |
167 |
|
|
s[ 0], s[ 1], s[ 2], s[ 3]); |
168 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f % 31.15f\n", |
169 |
|
|
s[ 4], s[ 5], s[ 6], s[ 7]); |
170 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f % 31.15f\n", |
171 |
|
|
s[ 8], s[ 9], s[10], s[11]); |
172 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f % 31.15f\n", |
173 |
|
|
s[12], s[13], s[14], s[15]); |
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
void |
177 |
|
|
ell_4v_print_d(FILE *f, const double s[4]) { |
178 |
|
|
|
179 |
|
|
fprintf(f, "% 31.15f % 31.15f % 31.15f % 31.15f\n", |
180 |
|
|
s[0], s[1], s[2], s[3]); |
181 |
|
|
} |