/usr/include/teem/tenMacros.h is in libteem-dev 1.11.0~svn5226-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | /*
Teem: Tools to process and visualize scientific data and images
Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann
Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
(LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The terms of redistributing and/or modifying this software also
include exceptions to the LGPL that facilitate static linking.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TENMACROS_HAS_BEEN_INCLUDED
#define TENMACROS_HAS_BEEN_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/*
******** TEN_T2M, TEN_M2T
**
** for going between 7-element list and 9-element matrix
** representations of a symmetric tensor
**
** the ordering of the tensor elements is assumed to be:
**
** threshold 0
** Dxx Dxy Dxz 1 2 3
** Dxy Dyy Dyz = (2) 4 5
** Dxz Dyz Dzz (3) (5) 6
**
** As in ell, the matrix ordering is given by:
**
** 0 1 2
** 3 4 5
** 6 7 8
**
** Note that TEN_M2T does NOT set the threshold element (index 0),
** and that the threshold value plays no role in TEN_T2M.
*/
#define TEN_T2M(m, t) ( \
(m)[0] = (t)[1], (m)[1] = (t)[2], (m)[2] = (t)[3], \
(m)[3] = (t)[2], (m)[4] = (t)[4], (m)[5] = (t)[5], \
(m)[6] = (t)[3], (m)[7] = (t)[5], (m)[8] = (t)[6] )
/* Tue Feb 19 16:36:53 GMT 2008: trying averaging the off-diagonal
elements to make better sense of matrices which aren't quite
symmetric */
#define TEN_M2T(t, m) ( \
(t)[1] = (m)[0], \
(t)[2] = ((m)[1]+(m)[3])/2.0, \
(t)[3] = ((m)[2]+(m)[6])/2.0, \
(t)[4] = (m)[4], \
(t)[5] = ((m)[5]+(m)[7])/2.0, \
(t)[6] = (m)[8] )
#define TEN_M2T_TT(t, TT, m) ( \
(t)[1] = AIR_CAST(TT, (m)[0]), \
(t)[2] = AIR_CAST(TT, ((m)[1]+(m)[3])/2.0), \
(t)[3] = AIR_CAST(TT, ((m)[2]+(m)[6])/2.0), \
(t)[4] = AIR_CAST(TT, (m)[4]), \
(t)[5] = AIR_CAST(TT, ((m)[5]+(m)[7])/2.0), \
(t)[6] = AIR_CAST(TT, (m)[8]))
#define TEN_TV_MUL(v2, t, v1) \
((v2)[0] = (t)[1]*(v1)[0] + (t)[2]*(v1)[1] + (t)[3]*(v1)[2], \
(v2)[1] = (t)[2]*(v1)[0] + (t)[4]*(v1)[1] + (t)[5]*(v1)[2], \
(v2)[2] = (t)[3]*(v1)[0] + (t)[5]*(v1)[1] + (t)[6]*(v1)[2])
#define TEN_T_EXISTS(t) ( \
AIR_EXISTS((t)[0]) \
&& AIR_EXISTS((t)[1]) \
&& AIR_EXISTS((t)[2]) \
&& AIR_EXISTS((t)[3]) \
&& AIR_EXISTS((t)[4]) \
&& AIR_EXISTS((t)[5]) \
&& AIR_EXISTS((t)[6]) )
#define TEN_T_SET(t, conf, a, b, c, d, e, f) ( \
(t)[0] = (conf), \
(t)[1] = (a), (t)[2] = (b), (t)[3] = (c), \
(t)[4] = (d), (t)[5] = (e), \
(t)[6] = (f) )
#define TEN_T_SET_TT(t, TT, conf, a, b, c, d, e, f) ( \
(t)[0] = AIR_CAST(TT, (conf)), \
(t)[1] = AIR_CAST(TT, (a)), \
(t)[2] = AIR_CAST(TT, (b)), \
(t)[3] = AIR_CAST(TT, (c)), \
(t)[4] = AIR_CAST(TT, (d)), \
(t)[5] = AIR_CAST(TT, (e)), \
(t)[6] = AIR_CAST(TT, (f)))
#define TEN_T_COPY(d, s) ( \
(d)[0] = (s)[0], \
(d)[1] = (s)[1], \
(d)[2] = (s)[2], \
(d)[3] = (s)[3], \
(d)[4] = (s)[4], \
(d)[5] = (s)[5], \
(d)[6] = (s)[6] )
#define TEN_T_COPY_TT(d, TT, s) ( \
(d)[0] = AIR_CAST(TT, (s)[0]), \
(d)[1] = AIR_CAST(TT, (s)[1]), \
(d)[2] = AIR_CAST(TT, (s)[2]), \
(d)[3] = AIR_CAST(TT, (s)[3]), \
(d)[4] = AIR_CAST(TT, (s)[4]), \
(d)[5] = AIR_CAST(TT, (s)[5]), \
(d)[6] = AIR_CAST(TT, (s)[6]) )
#define TEN_T_DET(t) ( \
(t)[1]*((t)[4]*(t)[6] - (t)[5]*(t)[5]) \
+ (t)[2]*((t)[5]*(t)[3] - (t)[2]*(t)[6]) \
+ (t)[3]*((t)[2]*(t)[5] - (t)[3]*(t)[4]))
#define TEN_T_DET_XY(t) ( (t)[1]*(t)[4] - (t)[2]*(t)[2] )
#define TEN_T_DET_XZ(t) ( (t)[1]*(t)[6] - (t)[3]*(t)[3] )
#define TEN_T_DET_YZ(t) ( (t)[4]*(t)[6] - (t)[5]*(t)[5] )
#define TEN_T_TRACE(t) ((t)[1] + (t)[4] + (t)[6])
#define TEN_T_INV(i, t, det) \
((det) = TEN_T_DET(t), \
(i)[0] = (t)[0], \
(i)[1] = _ELL_2M_DET((t)[4],(t)[5],(t)[5],(t)[6])/(det), \
(i)[2] = -_ELL_2M_DET((t)[2],(t)[5],(t)[3],(t)[6])/(det), \
(i)[3] = _ELL_2M_DET((t)[2],(t)[4],(t)[3],(t)[5])/(det), \
(i)[4] = _ELL_2M_DET((t)[1],(t)[3],(t)[3],(t)[6])/(det), \
(i)[5] = -_ELL_2M_DET((t)[1],(t)[2],(t)[3],(t)[5])/(det), \
(i)[6] = _ELL_2M_DET((t)[1],(t)[2],(t)[2],(t)[4])/(det))
#define TEN_T_DOT(A, B) ( \
(A)[1]*(B)[1] + 2*(A)[2]*(B)[2] + 2*(A)[3]*(B)[3] \
+ (A)[4]*(B)[4] + 2*(A)[5]*(B)[5] \
+ (A)[6]*(B)[6] )
#define TEN_T_NORM(A) (sqrt(TEN_T_DOT(A,A)))
#define TEN_T_ADD(a, b, c) ( \
(a)[0] = ((b)[0] + (c)[0])/2.0, \
(a)[1] = (b)[1] + (c)[1], \
(a)[2] = (b)[2] + (c)[2], \
(a)[3] = (b)[3] + (c)[3], \
(a)[4] = (b)[4] + (c)[4], \
(a)[5] = (b)[5] + (c)[5], \
(a)[6] = (b)[6] + (c)[6])
#define TEN_T_SUB(a, b, c) ( \
(a)[0] = ((b)[0] + (c)[0])/2.0, \
(a)[1] = (b)[1] - (c)[1], \
(a)[2] = (b)[2] - (c)[2], \
(a)[3] = (b)[3] - (c)[3], \
(a)[4] = (b)[4] - (c)[4], \
(a)[5] = (b)[5] - (c)[5], \
(a)[6] = (b)[6] - (c)[6])
#define TEN_T_AFFINE(C, i, x, I, A, B) ( \
(C)[0] = AIR_AFFINE((i), (x), (I), (A)[0], (B)[0]), \
(C)[1] = AIR_AFFINE((i), (x), (I), (A)[1], (B)[1]), \
(C)[2] = AIR_AFFINE((i), (x), (I), (A)[2], (B)[2]), \
(C)[3] = AIR_AFFINE((i), (x), (I), (A)[3], (B)[3]), \
(C)[4] = AIR_AFFINE((i), (x), (I), (A)[4], (B)[4]), \
(C)[5] = AIR_AFFINE((i), (x), (I), (A)[5], (B)[5]), \
(C)[6] = AIR_AFFINE((i), (x), (I), (A)[6], (B)[6]))
#define TEN_T_LERP(c, w, a, b) ( \
(c)[0] = AIR_LERP((w), (a)[0], (b)[0]), \
(c)[1] = AIR_LERP((w), (a)[1], (b)[1]), \
(c)[2] = AIR_LERP((w), (a)[2], (b)[2]), \
(c)[3] = AIR_LERP((w), (a)[3], (b)[3]), \
(c)[4] = AIR_LERP((w), (a)[4], (b)[4]), \
(c)[5] = AIR_LERP((w), (a)[5], (b)[5]), \
(c)[6] = AIR_LERP((w), (a)[6], (b)[6]))
#define TEN_T_SCALE(a, s, b) ( \
(a)[0] = (b)[0], \
(a)[1] = (s)*(b)[1], \
(a)[2] = (s)*(b)[2], \
(a)[3] = (s)*(b)[3], \
(a)[4] = (s)*(b)[4], \
(a)[5] = (s)*(b)[5], \
(a)[6] = (s)*(b)[6])
#define TEN_T_INCR(a, b) ( \
(a)[0] = (b)[0], \
(a)[1] += (b)[1], \
(a)[2] += (b)[2], \
(a)[3] += (b)[3], \
(a)[4] += (b)[4], \
(a)[5] += (b)[5], \
(a)[6] += (b)[6])
#define TEN_T_SCALE_INCR(a, s, b) ( \
(a)[0] = (b)[0], \
(a)[1] += (s)*(b)[1], \
(a)[2] += (s)*(b)[2], \
(a)[3] += (s)*(b)[3], \
(a)[4] += (s)*(b)[4], \
(a)[5] += (s)*(b)[5], \
(a)[6] += (s)*(b)[6])
#define TEN_T_SCALE_INCR2(a, s, b, t, c) ( \
(a)[0] = AIR_MIN((b)[0], (c)[0]), \
(a)[1] += (s)*(b)[1] + (t)*(c)[1], \
(a)[2] += (s)*(b)[2] + (t)*(c)[2], \
(a)[3] += (s)*(b)[3] + (t)*(c)[3], \
(a)[4] += (s)*(b)[4] + (t)*(c)[4], \
(a)[5] += (s)*(b)[5] + (t)*(c)[5], \
(a)[6] += (s)*(b)[6] + (t)*(c)[6])
#define TEN_T_SCALE_ADD2(a, s, b, t, c) ( \
(a)[0] = AIR_MIN((b)[0], (c)[0]), \
(a)[1] = (s)*(b)[1] + (t)*(c)[1], \
(a)[2] = (s)*(b)[2] + (t)*(c)[2], \
(a)[3] = (s)*(b)[3] + (t)*(c)[3], \
(a)[4] = (s)*(b)[4] + (t)*(c)[4], \
(a)[5] = (s)*(b)[5] + (t)*(c)[5], \
(a)[6] = (s)*(b)[6] + (t)*(c)[6])
#define TEN_T3V_MUL(b, t, a) ( \
(b)[0] = (t)[1]*(a)[0] + (t)[2]*(a)[1] + (t)[3]*(a)[2], \
(b)[1] = (t)[2]*(a)[0] + (t)[4]*(a)[1] + (t)[5]*(a)[2], \
(b)[2] = (t)[3]*(a)[0] + (t)[5]*(a)[1] + (t)[6]*(a)[2])
#define TEN_T3V_OUTER(t, a) ( \
(t)[0] = 1.0, \
(t)[1] = (a)[0]*(a)[0], (t)[2] = (a)[0]*(a)[1], (t)[3] = (a)[0]*(a)[2], \
(t)[4] = (a)[1]*(a)[1], (t)[5] = (a)[1]*(a)[2], \
(t)[6] = (a)[2]*(a)[2])
#define TEN_T3V_OUTER_INCR(t, a) ( \
(t)[1] += (a)[0]*(a)[0], (t)[2] += (a)[0]*(a)[1], (t)[3] += (a)[0]*(a)[2], \
(t)[4] += (a)[1]*(a)[1], (t)[5] += (a)[1]*(a)[2], \
(t)[6] += (a)[2]*(a)[2])
/* NOTE: never looks at (t)[0] */
#define TEN_T3V_CONTR(t, v) ( \
(v)[0]*(t)[1]*(v)[0] + (v)[0]*(t)[2]*(v)[1] + (v)[0]*(t)[3]*(v)[2] \
+ (v)[1]*(t)[2]*(v)[0] + (v)[1]*(t)[4]*(v)[1] + (v)[1]*(t)[5]*(v)[2] \
+ (v)[2]*(t)[3]*(v)[0] + (v)[2]*(t)[5]*(v)[1] + (v)[2]*(t)[6]*(v)[2])
#ifdef __cplusplus
}
#endif
#endif /* TENMACROS_HAS_BEEN_INCLUDED */
|