File size: 14,016 Bytes
10f2621 | 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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | /**
* @defgroup Vec3 Vec3 class
* @brief 3x1 vector object
* @defgroup Mat3 Mat3 class
* @brief 3x3 dense matrix object
*/
/**
* @file vec3.h
* @ingroup Vec3 Mat3
* @brief Classes Vec3,Mat3: 3x1 vector and 3x3 dense matrix objects.
* @author Michael Holst
* @note None
* @version $Id: vec3.h,v 1.5 2010/08/12 05:18:36 fetk Exp $
*
* @attention
* @verbatim
*
* MC = < Manifold Code >
* Copyright (C) 1994-- Michael Holst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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 the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @endverbatim
*/
#ifndef _VEC3_H_
#define _VEC3_H_
#include <mc/mc_base.h>
/*
* ***************************************************************************
* Class Vec3,Mat3: Parameters and datatypes
* ***************************************************************************
*/
/*
* ***************************************************************************
* Class Vec3,Mat3: Definition
* ***************************************************************************
*/
/**
* @ingroup Vec3
* @brief Vec3 definition. 3x1 vector object
* @author Michael Holst
*/
typedef double Vec3[3];
/**
* @ingroup Mat3
* @brief Mat3 definition. 3x3 dense matrix object
* @author Michael Holst
*/
typedef double Mat3[3][3];
/*
* ***************************************************************************
* Class Vec3,Mat3: Inlineable methods (vec3.c)
* ***************************************************************************
*/
#if !defined(VINLINE_BAM)
#else /* if defined(VINLINE_BAM) */
#endif /* if !defined(VINLINE_BAM) */
/**
* @ingroup Vec3
* @brief 1-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 1-norm of a 3-vector
* @param u 3-vector
*/
VEXTERNC double Vec3_nrm1(Vec3 u);
/**
* @ingroup Vec3
* @brief 2-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 2-norm of a 3-vector
* @param u 3-vector
*/
VEXTERNC double Vec3_nrm2(Vec3 u);
/**
* @ingroup Vec3
* @brief oo-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return oo-norm of a 3-vector
* @param u 3-vector
*/
VEXTERNC double Vec3_nrm8(Vec3 u);
/**
* @ingroup Vec3
* @brief 1-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 1-norm of a 3-vector
* @param u 3-vector u
* @param v 3-vector v
*/
VEXTERNC double Vec3_dif1(Vec3 u, Vec3 v);
/**
* @ingroup Vec3
* @brief 2-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 2-norm of a 3-vector
* @param u 3-vector u
* @param v 3-vector v
*/
VEXTERNC double Vec3_dif2(Vec3 u, Vec3 v);
/**
* @ingroup Vec3
* @brief oo-norm of a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return oo-norm of a 3-vector
* @param u 3-vector u
* @param v 3-vector v
*/
VEXTERNC double Vec3_dif8(Vec3 u, Vec3 v);
/**
* @ingroup Vec3
* @brief dot product of two 3-vectors.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return dot product of two 3-vectors
* @param u 3-vector u
* @param v 3-vector v
*/
VEXTERNC double Vec3_dot(Vec3 u, Vec3 v);
/**
* @ingroup Vec3
* @brief Initialize a 3-vector to be a constant.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u 3-vector u
* @param val the constant to be initialized for a 3-vector
*/
VEXTERNC void Vec3_init(Vec3 u, double val);
/**
* @ingroup Vec3
* @brief 3-vector scale.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u 3-vector u
* @param val the constant to be initialized for a 3-vector
*/
VEXTERNC void Vec3_scal(Vec3 u, double val);
/**
* @ingroup Vec3
* @brief 3-vector copy.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the destiny 3-vector
* @param v the source 3-vector
*/
VEXTERNC void Vec3_copy(Vec3 u, Vec3 v);
/**
* @ingroup Vec3
* @brief scalar times 3-vector plus 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param v the source 3-vector
* @param val the coeficient for scaling 3-vector v
*/
VEXTERNC void Vec3_axpy(Vec3 u, Vec3 v, double val);
/**
* @ingroup Vec3
* @brief cross-product of two 3-vectors.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param v the source 3-vector
* @param w another source 3-vector
*/
VEXTERNC void Vec3_xcry(Vec3 u, Vec3 v, double *w);
/**
* @ingroup Vec3
* @brief normalize a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param scale scale value of the 3-vector u
*/
VEXTERNC void Vec3_nrmlize(Vec3 u, double scale);
/**
* @ingroup Vec3
* @brief normalize a 3-vector (no error check).
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param scale scale value of the 3-vector u
*/
VEXTERNC void Vec3_nrmlizeNE(Vec3 u, double scale);
/**
* @ingroup Vec3
* @brief print a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param name the output file name
*/
VEXTERNC void Vec3_print(Vec3 u, const char *name);
/**
* @ingroup Vec3
* @brief multiply a 3-matrix and a 3-vector.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param A the 3-matrix
* @param v the source 3-vector
*/
VEXTERNC void Vec3_mult(Vec3 u, Mat3 A, Vec3 v);
/**
* @ingroup Vec3
* @brief get 3-vector column of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param A the 3-matrix
* @param col the index of column
*/
VEXTERNC void Vec3_getCol(Vec3 u, Mat3 A, int col);
/**
* @ingroup Vec3
* @brief get 3-vector row of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param u the output 3-vector
* @param A the 3-matrix
* @param row the index of row
*/
VEXTERNC void Vec3_getRow(Vec3 u, Mat3 A, int row);
/**
* @ingroup Mat3
* @brief 1-norm of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 1-norm of a 3-matrix
* @param A the 3-matrix
*/
VEXTERNC double Mat3_nrm1(Mat3 A);
/**
* @ingroup Mat3
* @brief 2-norm of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 2-norm of a 3-matrix
* @param A the 3-matrix
*/
VEXTERNC double Mat3_nrm2(Mat3 A);
/**
* @ingroup Mat3
* @brief oo-norm of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return oo-norm of a 3-matrix
* @param A the 3-matrix
*/
VEXTERNC double Mat3_nrm8(Mat3 A);
/**
* @ingroup Mat3
* @brief 1-norm of difference of two 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 1-norm of difference of two 3-matrices
* @param A the 3-matrix A
* @param B the 3-matrix B
*/
VEXTERNC double Mat3_dif1(Mat3 A, Mat3 B);
/**
* @ingroup Mat3
* @brief 2-norm of difference of two 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return 2-norm of difference of two 3-matrices
* @param A the 3-matrix A
* @param B the 3-matrix B
*/
VEXTERNC double Mat3_dif2(Mat3 A, Mat3 B);
/**
* @ingroup Mat3
* @brief oo-norm of difference of two 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return oo-norm of difference of two 3-matrices
* @param A the 3-matrix A
* @param B the 3-matrix B
*/
VEXTERNC double Mat3_dif8(Mat3 A, Mat3 B);
/**
* @ingroup Mat3
* @brief oo-norm of lower-triangle of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return oo-norm of lower-triangle of a 3-matrix
* @param A the 3-matrix
*/
VEXTERNC double Mat3_nrm8Low(Mat3 A);
/**
* @ingroup Mat3
* @brief identity 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
*/
VEXTERNC void Mat3_eye(Mat3 A);
/**
* @ingroup Mat3
* @brief initialize a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param val initialized value of the 3-matrix component
*/
VEXTERNC void Mat3_init(Mat3 A, double val);
/**
* @ingroup Mat3
* @brief normalize a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param val the coeficient of the 3-matrix components
*/
VEXTERNC void Mat3_scal(Mat3 A, double val);
/**
* @ingroup Mat3
* @brief copy a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the output 3-matrix
* @param B the source 3-matrix
*/
VEXTERNC void Mat3_copy(Mat3 A, Mat3 B);
/**
* @ingroup Mat3
* @brief Saxpy for 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the output 3-matrix
* @param B the source 3-matrix
* @param val the coeficient of the 3-matrix B components
*/
VEXTERNC void Mat3_axpy(Mat3 A, Mat3 B, double val);
/**
* @ingroup Mat3
* @brief multiply 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param C the output 3-matrix
* @param A the source 3-matrix A
* @param B the source 3-matrix B
*/
VEXTERNC void Mat3_mult(Mat3 C, Mat3 A, Mat3 B);
/**
* @ingroup Mat3
* @brief put a 3-vector column in a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param u the 3-vector
* @param col the index of the 3-vector column in a 3-matrix
*/
VEXTERNC void Mat3_putCol(Mat3 A, Vec3 u, int col);
/**
* @ingroup Mat3
* @brief put a 3-vector row in a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param u the 3-vector
* @param row the index of the 3-vector row in a 3-matrix
*/
VEXTERNC void Mat3_putRow(Mat3 A, Vec3 u, int row);
/**
* @ingroup Mat3
* @brief print a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param name the output name of the 3-matrix
*/
VEXTERNC void Mat3_print(Mat3 A, const char *name);
/**
* @ingroup Mat3
* @brief QR iteration for 3-matrices.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return QR iteration for 3-matrices
* @param V the output 3-matrix
* @param D the diagonal 3-matrix
* @param A the source 3-matrix
*/
VEXTERNC double Mat3_qri(Mat3 V, Mat3 D, Mat3 A);
/**
* @ingroup Mat3
* @brief QR factorization of 3-matrix (via modified Graham-Schmidt).
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param Q the Q 3-matrix
* @param R the R 3-matrix
* @param A the source 3-matrix
*/
VEXTERNC void Mat3_gramSch(Mat3 Q, Mat3 R, Mat3 A);
/**
* @ingroup Mat3
* @brief a single QR iteration for a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param Q the Q 3-matrix
* @param R the R 3-matrix
* @param A the source 3-matrix
*/
VEXTERNC void Mat3_qr(Mat3 Q, Mat3 R, Mat3 A);
/**
* @ingroup Mat3
* @brief determinant of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return determinant of a 3-matrix
* @param A the 3-matrix
*/
VEXTERNC double Mat3_det(Mat3 A);
/**
* @ingroup Mat3
* @brief inverse of a 3-matrix.
* @author Michael Holst
* @note Class Vec3,Mat3: Non-inlineable methods (vec3.c)
* @return None
* @param A the 3-matrix
* @param Ainv inverse of a 3-matrix A
*/
VEXTERNC void Mat3_inverse(Mat3 A, Mat3 Ainv);
#endif /* _VEC3_H_ */
|