00001
00014 #ifndef _GAN_VECF_GEN_H
00015 #define _GAN_VECF_GEN_H
00016
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include <stdarg.h>
00020 #include <gandalf/common/misc_defs.h>
00021 #include <gandalf/common/misc_error.h>
00022
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026
00042 struct Gan_Matrix_f;
00043
00045 typedef struct Gan_Vector_f
00046 {
00047
00048 unsigned long rows;
00049
00050
00051 float *data;
00052
00053
00054 size_t data_size;
00055
00056
00057 Gan_Bool data_alloc;
00058
00059
00060 Gan_Bool struct_alloc;
00061 } Gan_Vector_f;
00062
00063 #define GAN_VECTORF_STRUCT_DEFINED
00064
00065 #include <gandalf/linalg/matf_gen.h>
00066 #include <gandalf/linalg/matf_square.h>
00067
00068
00069 Gan_Vector_f *gan_vecf_form_gen ( Gan_Vector_f *x, unsigned long rows,
00070 float *data, size_t data_size );
00071 void gan_vecf_free ( Gan_Vector_f *x );
00072 Gan_Vector_f *gan_vecf_set_size ( Gan_Vector_f *x, unsigned long rows );
00073 Gan_Vector_f *gan_vecf_fill_va ( Gan_Vector_f *x, unsigned long rows, ... );
00074 Gan_Vector_f *gan_vecf_fill_vap ( Gan_Vector_f *x, unsigned long rows,
00075 va_list *aptr );
00076 Gan_Vector_f *gan_vecf_fill_const_q ( Gan_Vector_f *x, unsigned long rows,
00077 float value );
00078 Gan_Bool gan_vecf_read_va ( const Gan_Vector_f *x, unsigned long rows, ... );
00079 Gan_Vector_f *gan_vecf_copy_q ( const Gan_Vector_f *x, Gan_Vector_f *y );
00080 Gan_Vector_f *gan_vecf_scale_q ( Gan_Vector_f *x, float a, Gan_Vector_f *y );
00081 Gan_Vector_f *gan_vecf_add_q ( Gan_Vector_f *x, Gan_Vector_f *y,
00082 Gan_Vector_f *z );
00083 Gan_Vector_f *gan_vecf_sub_q ( Gan_Vector_f *x, Gan_Vector_f *y,
00084 Gan_Vector_f *z );
00085 float gan_vecf_dot ( const Gan_Vector_f *x, const Gan_Vector_f *y );
00086 struct Gan_Matrix_f *gan_vecf_outer_q ( const Gan_Vector_f *x, const Gan_Vector_f *y,
00087 struct Gan_Matrix_f *A );
00088 struct Gan_SquMatrix_f *gan_vecf_outer_sym_q ( const Gan_Vector_f *x,
00089 struct Gan_SquMatrix_f *A );
00090 Gan_Vector_f *gan_vecf_insert ( Gan_Vector_f *x, unsigned long rx,
00091 const Gan_Vector_f *y, unsigned long ry,
00092 unsigned long rows );
00093 void gan_vecf_free_va ( Gan_Vector_f *x, ... );
00094 Gan_Vector_f *gan_vecf_insert_mat ( Gan_Vector_f *x, unsigned long rx,
00095 const struct Gan_Matrix_f *A, unsigned long ra,
00096 unsigned long ca,
00097 unsigned long rows );
00098 Gan_Vector_f *gan_vecf_insert_matT ( Gan_Vector_f *x, unsigned long rx,
00099 const struct Gan_Matrix_f *A, unsigned long ra,
00100 unsigned long ca,
00101 unsigned long rows );
00102 Gan_Bool gan_vecf_fprint ( FILE *fp, const Gan_Vector_f *x, const char *prefix,
00103 int indent, const char *fmt );
00104 Gan_Vector_f *gan_vecf_fscanf_q ( FILE *fp, Gan_Vector_f *x,
00105 char *prefix, int prefix_len );
00106 Gan_Bool gan_vecf_fwrite ( FILE *fp, const Gan_Vector_f *x, gan_uint32 magic_number );
00107 Gan_Vector_f *gan_vecf_fread_q ( FILE *fp, Gan_Vector_f *x,
00108 gan_uint32 *magic_number );
00109
00110 #define Gan_Matrix_f struct Gan_Matrix_f
00111 #define Gan_SquMatrix_f struct Gan_SquMatrix_f
00112
00126 Gan_Vector_f *gan_vecf_alloc ( unsigned long rows );
00127
00139 Gan_Vector_f *gan_vecf_form ( Gan_Vector_f *x, unsigned long rows );
00140
00155 Gan_Vector_f *gan_vecf_form_data ( Gan_Vector_f *x, unsigned long rows,
00156 void *data, size_t data_size );
00157
00173 Gan_Bool gan_vecf_set_el ( Gan_Vector_f *x, unsigned i, float value );
00174
00180 float gan_vecf_get_el ( const Gan_Vector_f *x, unsigned i );
00181
00188 Gan_Bool gan_vecf_inc_el ( Gan_Vector_f *x, unsigned i, float value );
00189
00196 Gan_Bool gan_vecf_dec_el ( Gan_Vector_f *x, unsigned i, float value );
00197
00214 Gan_Bool gan_vecf_print ( const Gan_Vector_f *x,
00215 const char *prefix, int indent, const char *fmt );
00216
00237 Gan_Vector_f *gan_vecf_fill_const_s ( unsigned long rows, float value );
00238
00249 Gan_Vector_f *gan_vecf_fill_zero_q ( Gan_Vector_f *x, unsigned long rows );
00250
00259 Gan_Vector_f *gan_vecf_fill_zero_s ( unsigned long rows );
00260
00275 Gan_Vector_f *gan_vecf_copy_s ( const Gan_Vector_f *x );
00276
00291 Gan_Vector_f *gan_vecf_scale_s ( Gan_Vector_f *x, float a );
00292
00299 Gan_Vector_f *gan_vecf_scale_i ( Gan_Vector_f *x, float a );
00300
00308 Gan_Vector_f *gan_vecf_divide_q ( Gan_Vector_f *x, float a, Gan_Vector_f *y );
00309
00315 Gan_Vector_f *gan_vecf_divide_s ( Gan_Vector_f *x, float a );
00316
00323 Gan_Vector_f *gan_vecf_divide_i ( Gan_Vector_f *x, float a );
00324
00330 Gan_Vector_f *gan_vecf_negate_q ( Gan_Vector_f *x, Gan_Vector_f *y );
00331
00337 Gan_Vector_f *gan_vecf_negate_s ( Gan_Vector_f *x );
00338
00344 Gan_Vector_f *gan_vecf_negate_i ( Gan_Vector_f *x );
00345
00362 Gan_Vector_f *gan_vecf_add_s ( Gan_Vector_f *x, Gan_Vector_f *y );
00363
00371 Gan_Vector_f *gan_vecf_add_i1 ( Gan_Vector_f *x, Gan_Vector_f *y );
00372
00380 Gan_Vector_f *gan_vecf_add_i2 ( Gan_Vector_f *x, Gan_Vector_f *y );
00381
00388 Gan_Vector_f *gan_vecf_increment ( Gan_Vector_f *x, Gan_Vector_f *y );
00389
00406 Gan_Vector_f *gan_vecf_sub_s ( Gan_Vector_f *x, Gan_Vector_f *y );
00407
00415 Gan_Vector_f *gan_vecf_sub_i1 ( Gan_Vector_f *x, Gan_Vector_f *y );
00416
00424 Gan_Vector_f *gan_vecf_sub_i2 ( Gan_Vector_f *x, Gan_Vector_f *y );
00425
00432 Gan_Vector_f *gan_vecf_decrement ( Gan_Vector_f *x, Gan_Vector_f *y );
00433
00449 Gan_Matrix_f *gan_vecf_outer_s ( const Gan_Vector_f *x, Gan_Vector_f *y );
00450
00458 Gan_SquMatrix_f *gan_vecf_outer_sym_s ( const Gan_Vector_f *x );
00459
00475 float gan_vecf_sqrlen ( const Gan_Vector_f *x );
00476
00494 Gan_Bool gan_vecf_same_size ( const Gan_Vector_f *x, const Gan_Vector_f *y );
00495
00511 size_t gan_vecf_data_size ( unsigned long rows );
00512
00534 Gan_Vector_f *gan_vecf_fscanf_s ( FILE *fp, const char *prefix,
00535 int prefix_len );
00536
00546 Gan_Vector_f *gan_vecf_fread_s ( FILE *fp, gan_uint32 *magic_number );
00547
00552 #undef Gan_Matrix_f
00553 #undef Gan_SquMatrix_f
00554
00555
00556 Gan_Bool gan_vecf_realloc ( Gan_Vector_f *x, unsigned long rows );
00557 #ifndef NDEBUG
00558 void gan_vecf_db ( const Gan_Vector_f *x );
00559 #endif
00560
00573 #ifdef __cplusplus
00574 }
00575 #endif
00576
00577 #endif