Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SPARSE_MATRIX_H
00029
00030 #define SPARSE_MATRIX_H
00031
00032 #include "Const.h"
00033
00034 #define POS_ZERO_TOLERANCE 0.0000000001
00035 #define NEG_ZERO_TOLERANCE -0.0000000001
00036
00037 #define IS_ZERO(X) ((X < POS_ZERO_TOLERANCE) && ( X > NEG_ZERO_TOLERANCE ))
00038
00039
00040
00041
00042
00043
00044
00045
00046 typedef struct I_Matrix_Row_Node_Struct *I_Matrix_Row_Node;
00047 struct I_Matrix_Row_Node_Struct {
00048 int column;
00049 REAL_VALUE value;
00050 I_Matrix_Row_Node next;
00051 };
00052
00053
00054
00055
00056 struct I_Matrix_Struct {
00057 int num_rows;
00058 I_Matrix_Row_Node *row;
00059
00060 int *row_length;
00061
00062 };
00063 typedef struct I_Matrix_Struct *I_Matrix;
00064
00065
00066
00067 struct Matrix_Struct {
00068 int num_rows;
00069 int num_non_zero;
00070 REAL_VALUE *mat_val;
00071 int *row_start;
00072 int *row_length;
00073 int *col;
00074 };
00075 typedef struct Matrix_Struct *Matrix;
00076
00077
00078
00079
00080 #ifdef __cplusplus
00081 extern "C" {
00082 #endif
00083
00084 extern void destroyRow( I_Matrix_Row_Node row );
00085 extern I_Matrix_Row_Node addEntryToRow( I_Matrix_Row_Node row,
00086 int col, REAL_VALUE value,
00087 int *count, int accumulate );
00088 extern void displayRow( I_Matrix_Row_Node row );
00089
00090 extern int addEntryToIMatrix( I_Matrix i_matrix, int row,
00091 int col, REAL_VALUE value );
00092 extern int accumulateEntryInIMatrix( I_Matrix i_matrix, int row,
00093 int col, REAL_VALUE value );
00094 extern void destroyIMatrix( I_Matrix i_matrix );
00095 extern I_Matrix newIMatrix( int num_rows );
00096 extern REAL_VALUE sumIMatrixRowValues( I_Matrix i_matrix, int row );
00097 extern Matrix newMatrix( int num_rows, int num_non_zero );
00098 extern void destroyMatrix( Matrix matrix );
00099 extern Matrix transformIMatrix( I_Matrix i_matrix );
00100 extern void displayMatrix( Matrix matrix );
00101 extern REAL_VALUE sumRowValues( Matrix matrix, int row );
00102 extern REAL_VALUE getEntryMatrix( Matrix matrix, int row, int col );
00103
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107
00108 #endif