Main Page | Modules | Class List | File List | Class Members | File Members

vec_gen.h

Go to the documentation of this file.
00001 
00014 /* This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Lesser General Public
00016    License as published by the Free Software Foundation; either
00017    version 2.1 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser General Public
00025    License along with this library; if not, write to the Free Software
00026    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 */
00028 
00029 #ifndef _GAN_VEC_GEN_H
00030 #define _GAN_VEC_GEN_H
00031 
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <stdarg.h>
00035 #include <gandalf/common/misc_defs.h>
00036 #include <gandalf/common/misc_error.h>
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00057 struct Gan_Matrix;
00058 
00060 typedef struct Gan_Vector
00061 {
00062    /* size of column vector */
00063    unsigned long rows;
00064 
00065    /* data array containing vector elements */
00066    double *data;
00067 
00068    /* allocated size of vector (number of double's) */
00069    size_t data_size;
00070 
00071    /* flag indicating whether vector data was dynamically allocated */
00072    Gan_Bool data_alloc;
00073 
00074    /* flag indicating whether vector structure was dynamically allocated */
00075    Gan_Bool struct_alloc;
00076 } Gan_Vector;
00077 
00078 #define GAN_VECTOR_STRUCT_DEFINED
00079 
00080 #include <gandalf/linalg/mat_gen.h>
00081 #include <gandalf/linalg/mat_square.h>
00082 
00083 /* function declarations */
00084  Gan_Vector *gan_vec_form_gen ( Gan_Vector *x, unsigned long rows,
00085                                double *data, size_t data_size );
00086  void gan_vec_free ( Gan_Vector *x );
00087  Gan_Vector *gan_vec_set_size ( Gan_Vector *x, unsigned long rows );
00088  Gan_Vector *gan_vec_fill_va ( Gan_Vector *x, unsigned long rows, ... );
00089  Gan_Vector *gan_vec_fill_vap ( Gan_Vector *x, unsigned long rows,
00090                                va_list *aptr );
00091  Gan_Vector *gan_vec_fill_const_q ( Gan_Vector *x, unsigned long rows,
00092                                    double value );
00093  Gan_Bool gan_vec_read_va ( const Gan_Vector *x, unsigned long rows, ... );
00094  Gan_Vector *gan_vec_copy_q ( const Gan_Vector *x, Gan_Vector *y );
00095  Gan_Vector *gan_vec_scale_q ( Gan_Vector *x, double a, Gan_Vector *y );
00096  Gan_Vector *gan_vec_add_q ( Gan_Vector *x, Gan_Vector *y, Gan_Vector *z );
00097  Gan_Vector *gan_vec_sub_q ( Gan_Vector *x, Gan_Vector *y, Gan_Vector *z );
00098  double gan_vec_dot ( const Gan_Vector *x, const Gan_Vector *y );
00099  struct Gan_Matrix *gan_vec_outer_q ( const Gan_Vector *x, const Gan_Vector *y,
00100                                      struct Gan_Matrix *A );
00101  struct Gan_SquMatrix *gan_vec_outer_sym_q ( const Gan_Vector *x,
00102                                             struct Gan_SquMatrix *A );
00103  Gan_Vector *gan_vec_insert ( Gan_Vector *x, unsigned long rx,
00104                              const Gan_Vector *y, unsigned long ry,
00105                              unsigned long rows );
00106  void gan_vec_free_va ( Gan_Vector *x, ... );
00107  Gan_Vector *gan_vec_insert_mat ( Gan_Vector *x, unsigned long rx,
00108                                  const struct Gan_Matrix *A, unsigned long ra,
00109                                                              unsigned long ca,
00110                                  unsigned long rows );
00111  Gan_Vector *gan_vec_insert_matT ( Gan_Vector *x, unsigned long rx,
00112                                   const struct Gan_Matrix *A, unsigned long ra,
00113                                                               unsigned long ca,
00114                                   unsigned long rows );
00115  Gan_Bool gan_vec_fprint ( FILE *fp, const Gan_Vector *x, const char *prefix,
00116                           int indent, const char *fmt );
00117  Gan_Vector *gan_vec_fscanf_q ( FILE *fp, Gan_Vector *x,
00118                                char *prefix, int prefix_len );
00119  Gan_Bool gan_vec_fwrite ( FILE *fp, const Gan_Vector *x, gan_uint32 magic_number );
00120  Gan_Vector *gan_vec_fread_q ( FILE *fp, Gan_Vector *x,
00121                               gan_uint32 *magic_number );
00122 
00123 #define Gan_Matrix    struct Gan_Matrix
00124 #define Gan_SquMatrix struct Gan_SquMatrix
00125 
00139  Gan_Vector *gan_vec_alloc ( unsigned long rows );
00140 
00152  Gan_Vector *gan_vec_form ( Gan_Vector *x, unsigned long rows );
00153 
00168  Gan_Vector *gan_vec_form_data ( Gan_Vector *x, unsigned long rows,
00169                                 void *data, size_t data_size );
00170 
00186  Gan_Bool gan_vec_set_el ( Gan_Vector *x, unsigned i, double value );
00187 
00193  double gan_vec_get_el ( const Gan_Vector *x, unsigned i );
00194 
00201  Gan_Bool gan_vec_inc_el ( Gan_Vector *x, unsigned i, double value );
00202 
00209  Gan_Bool gan_vec_dec_el ( Gan_Vector *x, unsigned i, double value );
00210 
00227  Gan_Bool gan_vec_print ( const Gan_Vector *x,
00228                          const char *prefix, int indent, const char *fmt );
00229 
00250  Gan_Vector *gan_vec_fill_const_s ( unsigned long rows, double value );
00251 
00262  Gan_Vector *gan_vec_fill_zero_q ( Gan_Vector *x, unsigned long rows );
00263 
00272  Gan_Vector *gan_vec_fill_zero_s ( unsigned long rows );
00273 
00288  Gan_Vector *gan_vec_copy_s ( const Gan_Vector *x );
00289 
00304  Gan_Vector *gan_vec_scale_s ( Gan_Vector *x, double a );
00305 
00312  Gan_Vector *gan_vec_scale_i ( Gan_Vector *x, double a );
00313 
00321  Gan_Vector *gan_vec_divide_q ( Gan_Vector *x, double a, Gan_Vector *y );
00322 
00328  Gan_Vector *gan_vec_divide_s ( Gan_Vector *x, double a );
00329 
00336  Gan_Vector *gan_vec_divide_i ( Gan_Vector *x, double a );
00337 
00343  Gan_Vector *gan_vec_negate_q ( Gan_Vector *x, Gan_Vector *y );
00344 
00350  Gan_Vector *gan_vec_negate_s ( Gan_Vector *x );
00351 
00357  Gan_Vector *gan_vec_negate_i ( Gan_Vector *x );
00358 
00375  Gan_Vector *gan_vec_add_s ( Gan_Vector *x, Gan_Vector *y );
00376 
00384  Gan_Vector *gan_vec_add_i1 ( Gan_Vector *x, Gan_Vector *y );
00385 
00393  Gan_Vector *gan_vec_add_i2 ( Gan_Vector *x, Gan_Vector *y );
00394 
00401  Gan_Vector *gan_vec_increment ( Gan_Vector *x, Gan_Vector *y );
00402 
00419  Gan_Vector *gan_vec_sub_s ( Gan_Vector *x, Gan_Vector *y );
00420 
00428  Gan_Vector *gan_vec_sub_i1 ( Gan_Vector *x, Gan_Vector *y );
00429 
00437  Gan_Vector *gan_vec_sub_i2 ( Gan_Vector *x, Gan_Vector *y );
00438 
00445  Gan_Vector *gan_vec_decrement ( Gan_Vector *x, Gan_Vector *y );
00446 
00462  Gan_Matrix *gan_vec_outer_s ( const Gan_Vector *x, const Gan_Vector *y );
00463 
00471  Gan_SquMatrix *gan_vec_outer_sym_s ( const Gan_Vector *x );
00472 
00488  double gan_vec_sqrlen ( const Gan_Vector *x );
00489 
00507  Gan_Bool gan_vec_same_size ( const Gan_Vector *x, const Gan_Vector *y );
00508 
00524  size_t gan_vec_data_size ( unsigned long rows );
00525 
00547  Gan_Vector *gan_vec_fscanf_s ( FILE *fp, const char *prefix, int prefix_len );
00548 
00558  Gan_Vector *gan_vec_fread_s ( FILE *fp, gan_uint32 *magic_number );
00559 
00564 #undef Gan_Matrix
00565 #undef Gan_SquMatrix
00566 
00567 /* not user functions */
00568  Gan_Bool gan_vec_realloc ( Gan_Vector *x, unsigned long rows );
00569 #ifndef NDEBUG
00570  void gan_vec_db ( const Gan_Vector *x ); /* for use in a debugger */
00571 #endif
00572 
00585 #ifdef __cplusplus
00586 }
00587 #endif
00588 
00589 #endif /* #ifndef _GAN_VEC_GEN_H */

Generated on Fri Mar 17 12:44:48 2006 by  doxygen 1.3.9.1