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

matf_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_MATF_GEN_H
00030 #define _GAN_MATF_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 #include <gandalf/linalg/linalg_defs.h>
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00058 struct Gan_SquMatrix_f;
00059 
00061 typedef struct Gan_Matrix_f
00062 {
00063    /* row and column dimensions of matrix */
00064    unsigned long rows, cols;
00065 
00066    /* data array containing matrix elements */
00067    float *data;
00068 
00069    /* allocated size of matrix (number of float's) */
00070    size_t data_size;
00071 
00072    /* flag indicating whether matrix data was dynamically allocated */
00073    Gan_Bool data_alloc;
00074 
00075    /* flag indicating whether matrix structure was dynamically allocated */
00076    Gan_Bool struct_alloc;
00077 } Gan_Matrix_f;
00078 
00079 #define GAN_MATRIXF_STRUCT_DEFINED
00080 
00081 #include <gandalf/linalg/vecf_gen.h>
00082 #include <gandalf/linalg/matf_square.h>
00083 
00084  void gan_matf_free ( Gan_Matrix_f *A );
00085  Gan_Matrix_f *gan_matf_set_dims ( Gan_Matrix_f *A,
00086                                   unsigned long rows, unsigned long cols );
00087  Gan_Matrix_f *gan_matf_fill_va ( Gan_Matrix_f *A,
00088                                  unsigned long rows, unsigned long cols, ... );
00089  Gan_Matrix_f *gan_matf_fill_vap ( Gan_Matrix_f *A,
00090                                   unsigned long rows, unsigned long cols,
00091                                   va_list *aptr );
00092  Gan_Matrix_f *gan_matf_fill_const_q ( Gan_Matrix_f *A,
00093                                       unsigned long rows, unsigned long cols,
00094                                       float value );
00095  Gan_Bool gan_matf_read_va ( const Gan_Matrix_f *A,
00096                             unsigned long rows, unsigned long cols, ... );
00097  Gan_Matrix_f *gan_matf_copy_q ( const Gan_Matrix_f *A, Gan_Matrix_f *B );
00098  Gan_Matrix_f *gan_matf_scale_q ( Gan_Matrix_f *A, float a, Gan_Matrix_f *B );
00099  Gan_Matrix_f *gan_matf_divide_q ( Gan_Matrix_f *A, float a, Gan_Matrix_f *B );
00100  Gan_Matrix_f *gan_matf_tpose_q ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00101  Gan_Bool gan_matf_is_zero ( Gan_Matrix_f *A );
00102  Gan_Matrix_f *gan_matf_insertsym ( Gan_Matrix_f *A,
00103                                    unsigned long rA, unsigned long cA,
00104                                    const struct Gan_SquMatrix_f *B,
00105                                    unsigned long rB, unsigned long cB,
00106                                    unsigned long rows , unsigned long cols );
00107  void gan_matf_free_va ( Gan_Matrix_f *A, ... );
00108  Gan_Matrix_f *gan_matf_extract_q ( const Gan_Matrix_f *A,
00109                                    unsigned long r0,   unsigned long c0,
00110                                    unsigned long rows, unsigned long cols,
00111                                    Gan_Matrix_f *B );
00112  float gan_matf_sumsqr ( const Gan_Matrix_f *A );
00113  float gan_matf_Fnorm ( const Gan_Matrix_f *A );
00114  Gan_Matrix_f *gan_matf_invert_q ( const Gan_Matrix_f *A, Gan_Matrix_f *B );
00115  Gan_Bool gan_matf_fprint ( FILE *fp, const Gan_Matrix_f *A, const char *prefix,
00116                            unsigned indent, const char *fmt );
00117  Gan_Matrix_f *gan_matf_fscanf_q ( FILE *fp, Gan_Matrix_f *A,
00118                                   char *prefix, int prefix_len );
00119  Gan_Bool gan_matf_fwrite ( FILE *fp, const Gan_Matrix_f *A, gan_uint32 magic_number );
00120  Gan_Matrix_f *gan_matf_fread_q ( FILE *fp, Gan_Matrix_f *A,
00121                                  gan_uint32 *magic_number );
00122 
00123 #define Gan_SquMatrix_f struct Gan_SquMatrix_f
00124 
00138  Gan_Matrix_f *gan_matf_alloc ( unsigned long rows, unsigned long cols );
00139 
00151  Gan_Matrix_f *gan_matf_form ( Gan_Matrix_f *A,
00152                               unsigned long rows, unsigned long cols );
00153 
00168  Gan_Matrix_f *gan_matf_form_data ( Gan_Matrix_f *A,
00169                                    unsigned long rows, unsigned long cols,
00170                                    float *data, size_t data_size );
00171 
00187  Gan_Bool gan_matf_set_el ( Gan_Matrix_f *A,
00188                            unsigned i, unsigned j, float value);
00189 
00195  float gan_matf_get_el ( const Gan_Matrix_f *A, unsigned i, unsigned j );
00196 
00203  Gan_Bool gan_matf_inc_el ( Gan_Matrix_f *A,
00204                            unsigned i, unsigned j, float value);
00205 
00212  Gan_Bool gan_matf_dec_el ( Gan_Matrix_f *A,
00213                            unsigned i, unsigned j, float value);
00214 
00231  Gan_Bool gan_matf_print ( const Gan_Matrix_f *A,
00232                           const char *prefix, int indent, const char *fmt );
00233 
00255  Gan_Matrix_f *gan_matf_fill_const_s ( unsigned long rows, unsigned long cols,
00256                                       float value );
00257 
00268  Gan_Matrix_f *gan_matf_fill_zero_q ( Gan_Matrix_f *A,
00269                                      unsigned long rows, unsigned long cols );
00270 
00282  Gan_Matrix_f *gan_matf_fill_zero_s ( unsigned long rows, unsigned cols );
00283 
00298  Gan_Matrix_f *gan_matf_copy_s ( const Gan_Matrix_f *A );
00299 
00314  Gan_Matrix_f *gan_matf_scale_s ( Gan_Matrix_f *A, float a );
00315 
00321  Gan_Matrix_f *gan_matf_scale_i ( Gan_Matrix_f *A, float a );
00322 
00328  Gan_Matrix_f *gan_matf_divide_s ( Gan_Matrix_f *A, float a );
00329 
00335  Gan_Matrix_f *gan_matf_divide_i ( Gan_Matrix_f *A, float a );
00336 
00342  Gan_Matrix_f *gan_matf_negate_q ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00343 
00349  Gan_Matrix_f *gan_matf_negate_s ( Gan_Matrix_f *A );
00350 
00356  Gan_Matrix_f *gan_matf_negate_i ( Gan_Matrix_f *A );
00357 
00372  Gan_Matrix_f *gan_matf_tpose_s ( Gan_Matrix_f *A );
00373 
00380  Gan_Matrix_f *gan_matf_tpose_i ( Gan_Matrix_f *A );
00381 
00397  Gan_Matrix_f *gan_matf_add_q ( Gan_Matrix_f *A, Gan_Matrix_f *B,
00398                                Gan_Matrix_f *C );
00399 
00406  Gan_Matrix_f *gan_matf_add_s ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00407 
00414  Gan_Matrix_f *gan_matf_add_i1 ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00415 
00422  Gan_Matrix_f *gan_matf_add_i2 ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00423 
00430  Gan_Matrix_f *gan_matf_increment ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00431 
00438  Gan_Matrix_f *gan_matf_addT_q ( Gan_Matrix_f *A, Gan_Matrix_f *B,
00439                                 Gan_Matrix_f *C );
00440 
00447  Gan_Matrix_f *gan_matf_addT_s ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00448 
00455  Gan_Matrix_f *gan_matf_incrementT ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00456 
00464  Gan_SquMatrix_f *gan_matf_add_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00465                                       Gan_SquMatrix_f *C );
00466 
00474  Gan_SquMatrix_f *gan_matf_add_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00475 
00483  Gan_SquMatrix_f *gan_matf_addT_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00484                                        Gan_SquMatrix_f *C );
00485 
00493  Gan_SquMatrix_f *gan_matf_addT_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00494 
00502  Gan_SquMatrix_f *gan_matTf_add_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00503                                        Gan_SquMatrix_f *C );
00504 
00512  Gan_SquMatrix_f *gan_matTf_add_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00513 
00521  Gan_SquMatrix_f *gan_matTf_addT_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00522                                         Gan_SquMatrix_f *C );
00523 
00531  Gan_SquMatrix_f *gan_matTf_addT_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00532 
00539  Gan_SquMatrix_f *gan_matf_saddT_sym_q ( const Gan_Matrix_f *A, Gan_SquMatrix_f *B );
00540 
00547  Gan_SquMatrix_f *gan_matf_saddT_sym_s ( const Gan_Matrix_f *A );
00548 
00555  Gan_SquMatrix_f *gan_matTf_sadd_sym_q ( const Gan_Matrix_f *A, Gan_SquMatrix_f *B );
00556 
00563  Gan_SquMatrix_f *gan_matTf_sadd_sym_s ( const Gan_Matrix_f *A );
00564 
00580  Gan_Matrix_f *gan_matf_sub_q ( Gan_Matrix_f *A, Gan_Matrix_f *B, Gan_Matrix_f *C );
00581 
00588  Gan_Matrix_f *gan_matf_sub_s ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00589 
00596  Gan_Matrix_f *gan_matf_sub_i1 ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00597 
00604  Gan_Matrix_f *gan_matf_sub_i2 ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00605 
00612  Gan_Matrix_f *gan_matf_decrement ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00613 
00620  Gan_Matrix_f *gan_matf_subT_q ( Gan_Matrix_f *A, Gan_Matrix_f *B,
00621                                 Gan_Matrix_f *C );
00622 
00629  Gan_Matrix_f *gan_matf_subT_s ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00630 
00637  Gan_Matrix_f *gan_matf_decrementT ( Gan_Matrix_f *A, Gan_Matrix_f *B );
00638 
00654  Gan_Vector_f *gan_matf_multv_q ( const Gan_Matrix_f *A, const Gan_Vector_f *x,
00655                                  Gan_Vector_f *y );
00656 
00663  Gan_Vector_f *gan_matf_multv_s ( const Gan_Matrix_f *A, const Gan_Vector_f *x );
00664 
00671  Gan_Vector_f *gan_matTf_multv_q ( const Gan_Matrix_f *A, const Gan_Vector_f *x,
00672                                   Gan_Vector_f *y );
00673 
00680  Gan_Vector_f *gan_matTf_multv_s ( const Gan_Matrix_f *A, const Gan_Vector_f *x );
00681 
00697  Gan_Matrix_f *gan_matf_rmult_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00698                                  Gan_Matrix_f *C );
00699 
00706  Gan_Matrix_f *gan_matf_rmult_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00707 
00714  Gan_Matrix_f *gan_matf_rmultT_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00715                                   Gan_Matrix_f *C );
00716 
00723  Gan_Matrix_f *gan_matf_rmultT_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00724 
00731  Gan_Matrix_f *gan_matTf_rmult_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00732                                   Gan_Matrix_f *C );
00733 
00740  Gan_Matrix_f *gan_matTf_rmult_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00741 
00748  Gan_Matrix_f *gan_matTf_rmultT_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00749                                    Gan_Matrix_f *C );
00750 
00757  Gan_Matrix_f *gan_matTf_rmultT_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00758 
00766  Gan_SquMatrix_f *gan_matf_rmult_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00767                                         Gan_SquMatrix_f *C );
00768 
00776  Gan_SquMatrix_f *gan_matf_rmult_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00777 
00785  Gan_SquMatrix_f *gan_matf_rmultT_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00786                                          Gan_SquMatrix_f *C );
00787 
00795  Gan_SquMatrix_f *gan_matf_rmultT_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00796 
00804  Gan_SquMatrix_f *gan_matTf_rmult_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00805                                          Gan_SquMatrix_f *C );
00806 
00814  Gan_SquMatrix_f *gan_matTf_rmult_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00815 
00823  Gan_SquMatrix_f *gan_matTf_rmultT_sym_q ( const Gan_Matrix_f *A, const Gan_Matrix_f *B,
00824                                           Gan_SquMatrix_f *C );
00825 
00833  Gan_SquMatrix_f *gan_matTf_rmultT_sym_s ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00834 
00841  Gan_SquMatrix_f *gan_matf_srmultT_q ( const Gan_Matrix_f *A, Gan_SquMatrix_f *B );
00842 
00849  Gan_SquMatrix_f *gan_matf_srmultT_s ( const Gan_Matrix_f *A );
00850 
00857  Gan_SquMatrix_f *gan_matf_slmultT_q ( const Gan_Matrix_f *A, Gan_SquMatrix_f *B );
00858 
00865  Gan_SquMatrix_f *gan_matf_slmultT_s ( const Gan_Matrix_f *A );
00866 
00889  Gan_Matrix_f *gan_matf_invert_s ( const Gan_Matrix_f *A ) /* input matrix */;
00890 
00908  Gan_Bool gan_matf_same_dims ( const Gan_Matrix_f *A, const Gan_Matrix_f *B );
00909 
00928  Gan_Matrix_f *gan_matf_insert ( Gan_Matrix_f *A,
00929                                 unsigned long rA, unsigned long cA,
00930                                 const Gan_Matrix_f *B,
00931                                 unsigned long rB,   unsigned long cB,
00932                                 unsigned long rows, unsigned long cols )
00933 ;
00934 
00944  Gan_Matrix_f *gan_matf_insertT ( Gan_Matrix_f *A,
00945                                  unsigned long rA, unsigned long cA,
00946                                  const Gan_Matrix_f *B,
00947                                  unsigned long rB,   unsigned long cB,
00948                                  unsigned long rows, unsigned long cols );
00949 
00957  Gan_Matrix_f *gan_matf_insertv ( Gan_Matrix_f *A,
00958                                  unsigned long rA, unsigned long cA,
00959                                  const Gan_Vector_f *x, unsigned long rx,
00960                                  unsigned long rows );
00961 
00972  Gan_Matrix_f *gan_matf_insertvT ( Gan_Matrix_f *A,
00973                                   unsigned long rA, unsigned long cA,
00974                                   const Gan_Vector_f *x, unsigned long rx,
00975                                   unsigned long cols );
00976 
00992  Gan_Bool gan_matf_test_dims ( const Gan_Matrix_f *A, unsigned long rows,
00993                                                unsigned long cols );
00994 
01010  size_t gan_matf_data_size ( unsigned long rows, unsigned long cols );
01011 
01036  Gan_Matrix_f *gan_matf_extract_s ( const Gan_Matrix_f *A,
01037                                    unsigned long r0,   unsigned long c0,
01038                                    unsigned long rows, unsigned long cols );
01039 
01062  Gan_Matrix_f *gan_matf_fscanf_s ( FILE *fp, const char *prefix,
01063                                   int prefix_len );
01064 
01075  Gan_Matrix_f *gan_matf_fread_s ( FILE *fp, gan_uint32 *magic_number );
01076 
01081 #undef Gan_SquMatrix_f
01082 
01083 /* not user functions */
01084  Gan_Matrix_f *gan_matf_form_gen ( Gan_Matrix_f *A,
01085                                   unsigned long rows, unsigned long cols,
01086                                   float *data, size_t data_size );
01087  Gan_Bool gan_matf_realloc_gen ( Gan_Matrix_f *A,
01088                                 unsigned long rows, unsigned long cols );
01089  Gan_Matrix_f *gan_matf_add_gen ( Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01090                                  Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01091                                  Gan_Matrix_f *C );
01092  struct Gan_SquMatrix_f *gan_matf_add_sym_gen (
01093     const Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01094     const Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01095     struct Gan_SquMatrix_f *C );
01096  Gan_Matrix_f *gan_matf_sub_gen ( Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01097                                  Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01098                                  Gan_Matrix_f *C );
01099  Gan_Vector_f *gan_matf_multv_gen ( const Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01100                                    const Gan_Vector_f *x, Gan_Vector_f *y );
01101  Gan_Matrix_f *gan_matf_rmult_gen ( const Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01102                                    const Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01103                                    Gan_Matrix_f *C );
01104  struct Gan_SquMatrix_f *gan_matf_rmult_sym_gen (
01105     const Gan_Matrix_f *A, Gan_TposeFlag A_tr,
01106     const Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01107     struct Gan_SquMatrix_f *C );
01108  Gan_Matrix_f *gan_matf_insert_gen ( Gan_Matrix_f *A,
01109                                     unsigned long rA, unsigned long cA,
01110                                     const Gan_Matrix_f *B, Gan_TposeFlag B_tr,
01111                                     unsigned long rB, unsigned long cB,
01112                                     unsigned long rows , unsigned long cols );
01113  Gan_Matrix_f *gan_matf_insertv_gen ( Gan_Matrix_f *A,
01114                                      unsigned long rA, unsigned long cA,
01115                                      const struct Gan_Vector_f *x,
01116                                      Gan_TposeFlag x_tr,
01117                                      unsigned long rx, unsigned long size );
01118 
01119 #ifndef NDEBUG
01120  void gan_matf_db ( const Gan_Matrix_f *A ); /* for use in a debugger */
01121 #endif
01122 
01123 #define gan_matf_realloc(A,rows,cols) gan_matf_realloc_gen(A,rows,cols)
01124 
01125 #ifdef __cplusplus
01126 }
01127 #endif
01128 
01129 #endif /* #ifndef _GAN_MATF_GEN_H */

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