00001
00002
00003 #ifndef _SPARSEMATRIXF_H__
00004 #define _SPARSEMATRIXF_H__
00005
00006 #include "DSSAfx.h"
00007
00008 DSS_NAMESPASE_BEGIN
00009
00010 struct IConectMatrix;
00011
00012 struct SparseMatrixF
00013 {
00014 public:
00015 ULONG neq;
00016 double* a;
00017
00018 enum eOrientation
00019 {
00020 eCompressedRows,
00021 eCompressedColumns,
00022 eSymmetric
00023 };
00024
00025 private:
00026 ULONG* ci;
00027 ULONG* adr;
00028 ULONG Aoffset;
00029 ULONG Coffset;
00030 bool bJardaConvention;
00031 bool bLocalCopy;
00032 bool m_bIsSymmertric;
00033 eOrientation m_eSparseOrientation;
00034
00035 public:
00036 SparseMatrixF();
00037 SparseMatrixF(unsigned long neq,double* a,unsigned long* ci,unsigned long *adr,ULONG Aofs = 0,ULONG Cofs = 0,bool JardaConvention = true,bool bIsSymetric=true,eOrientation sparseOri=eCompressedColumns);
00038 SparseMatrixF(IConectMatrix* pConMtx);
00039 ~SparseMatrixF();
00040
00041 void Delete();
00042 void Detach();
00043 void CreateLocalCopy();
00044 void AddNumbers (double alfa,double* a);
00045 void ScaleMatrix(double alfa);
00046
00047 long Nonzeros();
00048 BOOL IsSymmetric() { return m_bIsSymmertric; }
00049 eOrientation GetOrientation() { return m_eSparseOrientation; }
00050 BOOL IsSamePattern(SparseMatrixF* sm);
00051
00052 void GetA12block(double* pA12,long c);
00053 void LoadMatrix(FILE* stream);
00054 void SaveMatrix(FILE *stream);
00055
00056 inline ULONG Adr(int i) const
00057 {
00058 if (bJardaConvention)
00059 return this->adr[i]-Aoffset;
00060 else
00061 {
00062 if (i==0)
00063 return 0;
00064 else
00065 return this->adr[i-1];
00066 }
00067 }
00068
00069 inline ULONG Ci(int i) const
00070 {
00071 return (this->ci[i])-Coffset;
00072 }
00073
00074
00075 void MulMatrixByVector(double *b,double *c);
00076
00077
00078 void MulNonsymMatrixByVector(double *b,double *c);
00079
00080
00081 void MulSymMatrixByVector(double *b,double *c);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 void mxv_scr (double *b,double *c);
00093
00094 void ReadDiagonal(double* dv);
00095
00096 };
00097
00098 DSS_NAMESPASE_END
00099
00100 #endif//_SPARSEMATRIXF_H__