00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _GAN_2VECTOR_H
00030 #define _GAN_2VECTOR_H
00031
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <gandalf/common/misc_defs.h>
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #ifndef _GAN_REPEAT2_H
00064 #define _GAN_REPEAT2_H
00065
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069
00070
00071 #define GAN_REP2_AS(a,b,p1,p2) (a p1 b, a p2 b)
00072 #define GAN_REP2_A(a,p1,p2) (a p1, a p2)
00073 #define GAN_REP2_AS_C(a,b) GAN_REP2_AS(a,b,x,y)
00074 #define GAN_REP2_A_C(a) GAN_REP2_A(a,x,y)
00075
00076 #define GAN_FREP2_A(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00077 #define GAN_FREP2_A_C(a,b,p1,p2) GAN_FREP2_A(a,b,x,y,p1,p2)
00078
00079 #define GAN_REP2_AB(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00080 #define GAN_REP2_AA(a,b,p1,p2) GAN_REP2_AB(a,b,p1,p2,p1,p2)
00081 #define GAN_REP2_AA_C(a,b) GAN_REP2_AA(a,b,x,y)
00082
00083 #define GAN_REP2_ABS(a,b,c,p1,p2,q1,q2) (a p1 b q1 c, a p2 b q2 c)
00084 #define GAN_REP2_AAS(a,b,c,p1,p2) GAN_REP2_ABS(a,b,c,p1,p2,p1,p2)
00085 #define GAN_REP2_AAS_C(a,b,c) GAN_REP2_AAS(a,b,c,x,y)
00086
00087 #define GAN_REP2_AB(a,b,p1,p2,q1,q2) (a p1 b q1, a p2 b q2)
00088 #define GAN_REP2_AA(a,b,p1,p2) GAN_REP2_AB(a,b,p1,p2,p1,p2)
00089 #define GAN_REP2_AA_C(a,b) GAN_REP2_AA(a,b,x,y)
00090
00091 #define GAN_REP2_ABCS(a,b,c,d,p1,p2,q1,q2,r1,r2)\
00092 (a p1 b q1 c r1 d, a p2 b q2 c r2 d)
00093 #define GAN_REP2_ABC(a,b,c,p1,p2,q1,q2,r1,r2)\
00094 (a p1 b q1 c r1, a p2 b q2 c r2)
00095 #define GAN_REP2_AAA(a,b,c,p1,p2) GAN_REP2_ABC(a,b,c,p1,p2,p1,p2,p1,p2)
00096 #define GAN_REP2_AAA_C(a,b,c) GAN_REP2_AAA(a,b,c,x,y)
00097
00098 #define GAN_REP2_OP_AB(a,b,p1,p2,q1,q2,op)\
00099 (a p1 b q1 op a p2 b q2)
00100 #define GAN_REP2_OP_AA(a,b,p1,p2,op) GAN_REP2_OP_AB(a,b,p1,p2,p1,p2,op)
00101 #define GAN_REP2_OP_AA_C(a,b,op) GAN_REP2_OP_AA(a,b,x,y,op)
00102
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106
00107 #endif
00108
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #ifndef _GAN_MATVECF_MACROS_H
00137 #define _GAN_MATVECF_MACROS_H
00138
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142
00143
00144
00145 #define GAN_TEST_OP1(A,typeA) assert(sizeof(*(A))==sizeof(typeA))
00146 #define GAN_TEST_OP2(A,B,typeA,typeB)\
00147 (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)))
00148 #define GAN_TEST_OP3(A,B,C,typeA,typeB,typeC)\
00149 (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00150 sizeof(*(C))==sizeof(typeC)))
00151 #define GAN_TEST_OP4(A,B,C,D,typeA,typeB,typeC,typeD)\
00152 (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00153 sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)))
00154 #define GAN_TEST_OP5(A,B,C,D,E,typeA,typeB,typeC,typeD,typeE)\
00155 (assert(sizeof(*(A))==sizeof(typeA)&&sizeof(*(B))==sizeof(typeB)&&\
00156 sizeof(*(C))==sizeof(typeC)&&sizeof(*(D))==sizeof(typeD)&&\
00157 sizeof(*(E))==sizeof(typeE)))
00158
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162
00163 #endif
00164 #include <gandalf/linalg/vec_gen.h>
00165
00166 #ifdef __cplusplus
00167 extern "C" {
00168 #endif
00169
00185
00186 typedef struct Gan_Vector2
00187 {
00188 double x, y;
00189 } Gan_Vector2, Gan_Vector2_d;
00190
00192 typedef struct Gan_Vector2_uc
00193 {
00194 unsigned char x, y;
00195 } Gan_Vector2_uc;
00196
00198 typedef struct Gan_Vector2_s
00199 {
00200 short x, y;
00201 } Gan_Vector2_s;
00202
00204 typedef struct Gan_Vector2_us
00205 {
00206 unsigned short x, y;
00207 } Gan_Vector2_us;
00208
00210 typedef struct Gan_Vector2_i
00211 {
00212 int x, y;
00213 } Gan_Vector2_i;
00214
00216 typedef struct Gan_Vector2_ui
00217 {
00218 unsigned int x, y;
00219 } Gan_Vector2_ui;
00220
00222 #if (SIZEOF_DOUBLE == 8)
00223 typedef struct Gan_Vector2 Gan_Vector2_f64;
00224 #endif
00225
00226 #if (SIZEOF_CHAR == 1)
00227 typedef struct Gan_Vector2_uc Gan_Vector2_ui8;
00228 #endif
00229
00230 #if (SIZEOF_SHORT == 2)
00231 typedef struct Gan_Vector2_s Gan_Vector2_i16;
00232 typedef struct Gan_Vector2_us Gan_Vector2_ui16;
00233 #endif
00234
00235 #if (SIZEOF_INT == 4)
00236 typedef struct Gan_Vector2_i Gan_Vector2_i32;
00237 typedef struct Gan_Vector2_ui Gan_Vector2_ui32;
00238 #endif
00239
00240
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00283 Gan_Vector2 *gan_vec2_fill_q ( Gan_Vector2 *p, double X, double Y );
00284
00290 #define GAN_VECTYPE Gan_Vector2
00291 #define GAN_VECTOR_TYPE Gan_Vector
00292 #define GAN_VEC_ELEMENT_TYPE GAN_DOUBLE
00293 #define GAN_REALTYPE double
00294 #define GAN_FWRITE_LENDIAN gan_fwrite_lendian_f64
00295 #define GAN_FREAD_LENDIAN gan_fread_lendian_f64
00296 #define GAN_VEC_FPRINT gan_vec2_fprint
00297 #define GAN_VEC_PRINT gan_vec2_print
00298 #define GAN_VEC_FSCANF gan_vec2_fscanf
00299 #define GAN_VEC_FWRITE gan_vec2_fwrite
00300 #define GAN_VEC_FREAD gan_vec2_fread
00301 #define GAN_VEC_ZERO_Q gan_vec2_zero_q
00302 #define GAN_VEC_ZERO_S gan_vec2_zero_s
00303 #define GAN_VEC_COPY_Q gan_vec2_copy_q
00304 #define GAN_VEC_COPY_S gan_vec2_copy_s
00305 #define GAN_VEC_SCALE_Q gan_vec2_scale_q
00306 #define GAN_VEC_SCALE_S gan_vec2_scale_s
00307 #define GAN_VEC_SCALE_I gan_vec2_scale_i
00308 #define GAN_VEC_DIVIDE_Q gan_vec2_divide_q
00309 #define GAN_VEC_DIVIDE_S gan_vec2_divide_s
00310 #define GAN_VEC_DIVIDE_I gan_vec2_divide_i
00311 #define GAN_VEC_NEGATE_Q gan_vec2_negate_q
00312 #define GAN_VEC_NEGATE_S gan_vec2_negate_s
00313 #define GAN_VEC_NEGATE_I gan_vec2_negate_i
00314 #define GAN_VEC_UNIT_Q gan_vec2_unit_q
00315 #define GAN_VEC_UNIT_S gan_vec2_unit_s
00316 #define GAN_VEC_UNIT_I gan_vec2_unit_i
00317 #define GAN_VEC_ADD_Q gan_vec2_add_q
00318 #define GAN_VEC_ADD_I1 gan_vec2_add_i1
00319 #define GAN_VEC_ADD_I2 gan_vec2_add_i2
00320 #define GAN_VEC_INCREMENT gan_vec2_increment
00321 #define GAN_VEC_ADD_S gan_vec2_add_s
00322 #define GAN_VEC_SUB_Q gan_vec2_sub_q
00323 #define GAN_VEC_SUB_I1 gan_vec2_sub_i1
00324 #define GAN_VEC_SUB_I2 gan_vec2_sub_i2
00325 #define GAN_VEC_DECREMENT gan_vec2_decrement
00326 #define GAN_VEC_SUB_S gan_vec2_sub_s
00327 #define GAN_VEC_DOT_Q gan_vec2_dot_q
00328 #define GAN_VEC_DOT_S gan_vec2_dot_s
00329 #define GAN_VEC_SQRLEN_Q gan_vec2_sqrlen_q
00330 #define GAN_VEC_SQRLEN_S gan_vec2_sqrlen_s
00331 #define GAN_VEC_FROM_VEC_Q gan_vec2_from_vec_q
00332 #define GAN_VEC_FROM_VEC_S gan_vec2_from_vec_s
00333
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00377 Gan_Vector2 *gan_vec2_zero_q ( Gan_Vector2 *p );
00378
00393 Gan_Vector2 *gan_vec2_copy_q ( Gan_Vector2 *p, Gan_Vector2 *q );
00394
00410 Gan_Vector2 *gan_vec2_scale_q ( Gan_Vector2 *p, double a,
00411 Gan_Vector2 *q );
00412
00418 Gan_Vector2 *gan_vec2_scale_i ( Gan_Vector2 *p, double a );
00419
00426 Gan_Vector2 *gan_vec2_divide_q ( Gan_Vector2 *p, double a,
00427 Gan_Vector2 *q );
00428
00434 Gan_Vector2 *gan_vec2_divide_i ( Gan_Vector2 *p, double a );
00435
00443 Gan_Vector2 *gan_vec2_negate_q ( Gan_Vector2 *p, Gan_Vector2 *q );
00444
00452 Gan_Vector2 *gan_vec2_negate_i ( Gan_Vector2 *p );
00453
00459 Gan_Vector2 *gan_vec2_unit_i ( Gan_Vector2 *p );
00460
00478 Gan_Vector2 *gan_vec2_add_q ( Gan_Vector2 *p, Gan_Vector2 *q, Gan_Vector2 *r );
00479
00488 Gan_Vector2 *gan_vec2_add_i1 ( Gan_Vector2 *p, Gan_Vector2 *q );
00489
00498 Gan_Vector2 *gan_vec2_add_i2 ( Gan_Vector2 *p, Gan_Vector2 *q );
00499
00508 Gan_Vector2 *gan_vec2_increment ( Gan_Vector2 *p, Gan_Vector2 *q );
00509
00527 Gan_Vector2 *gan_vec2_sub_q ( Gan_Vector2 *p, Gan_Vector2 *q, Gan_Vector2 *r );
00528
00537 Gan_Vector2 *gan_vec2_sub_i1 ( Gan_Vector2 *p, Gan_Vector2 *q );
00538
00547 Gan_Vector2 *gan_vec2_sub_i2 ( Gan_Vector2 *p, Gan_Vector2 *q );
00548
00557 Gan_Vector2 *gan_vec2_decrement ( Gan_Vector2 *p, Gan_Vector2 *q );
00558
00574 double gan_vec2_dot_q ( const Gan_Vector2 *p, const Gan_Vector2 *q );
00575
00593 double gan_vec2_sqrlen_q ( const Gan_Vector2 *p );
00594
00604 Gan_Vector2 gan_vec2_from_vec_s ( const Gan_Vector *x );
00605
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 #undef GAN_VECTYPE
00639 #undef GAN_VECTOR_TYPE
00640 #undef GAN_VEC_ELEMENT_TYPE
00641 #undef GAN_REALTYPE
00642 #undef GAN_FWRITE_LENDIAN
00643 #undef GAN_FREAD_LENDIAN
00644 #undef GAN_VEC_FPRINT
00645 #undef GAN_VEC_PRINT
00646 #undef GAN_VEC_FSCANF
00647 #undef GAN_VEC_FWRITE
00648 #undef GAN_VEC_FREAD
00649 #undef GAN_VEC_ZERO_Q
00650 #undef GAN_VEC_ZERO_S
00651 #undef GAN_VEC_COPY_Q
00652 #undef GAN_VEC_COPY_S
00653 #undef GAN_VEC_SCALE_Q
00654 #undef GAN_VEC_SCALE_S
00655 #undef GAN_VEC_SCALE_I
00656 #undef GAN_VEC_DIVIDE_Q
00657 #undef GAN_VEC_DIVIDE_S
00658 #undef GAN_VEC_DIVIDE_I
00659 #undef GAN_VEC_NEGATE_Q
00660 #undef GAN_VEC_NEGATE_S
00661 #undef GAN_VEC_NEGATE_I
00662 #undef GAN_VEC_UNIT_Q
00663 #undef GAN_VEC_UNIT_S
00664 #undef GAN_VEC_UNIT_I
00665 #undef GAN_VEC_ADD_Q
00666 #undef GAN_VEC_ADD_I1
00667 #undef GAN_VEC_ADD_I2
00668 #undef GAN_VEC_INCREMENT
00669 #undef GAN_VEC_ADD_S
00670 #undef GAN_VEC_SUB_Q
00671 #undef GAN_VEC_SUB_I1
00672 #undef GAN_VEC_SUB_I2
00673 #undef GAN_VEC_DECREMENT
00674 #undef GAN_VEC_SUB_S
00675 #undef GAN_VEC_DOT_Q
00676 #undef GAN_VEC_DOT_S
00677 #undef GAN_VEC_SQRLEN_Q
00678 #undef GAN_VEC_SQRLEN_S
00679 #undef GAN_VEC_FROM_VEC_Q
00680 #undef GAN_VEC_FROM_VEC_S
00681
00694 #ifdef __cplusplus
00695 }
00696 #endif
00697
00698 #endif