00001
00002 #ifndef __MAT_RECORD_H__
00003 #define __MAT_RECORD_H__
00004
00005 #include "petsc.h"
00006
00007 namespace ot {
00008
00013 class MatRecord {
00014 public:
00015
00016 unsigned int rowIdx;
00019 unsigned int colIdx;
00022 unsigned int rowDim;
00025 unsigned int colDim;
00028 PetscScalar val;
00032
00036 MatRecord() {
00037 rowIdx = colIdx = rowDim = colDim = static_cast<unsigned int>(-1);
00038 val = 0;
00039 }
00040
00044 MatRecord(const MatRecord & other) {
00045 rowIdx = other.rowIdx;
00046 colIdx = other.colIdx;
00047 rowDim = other.rowDim;
00048 colDim = other.colDim;
00049 val = other.val;
00050 }
00052
00056 MatRecord & operator = (MatRecord const & other) {
00057 if(this == (&other)) {return *this;}
00058 rowIdx = other.rowIdx;
00059 colIdx = other.colIdx;
00060 rowDim = other.rowDim;
00061 colDim = other.colDim;
00062 val = other.val;
00063 return *this;
00064 }
00065
00068 bool operator == ( MatRecord const &other) const {
00069 return ( (rowIdx == other.rowIdx) && (colIdx == other.colIdx)
00070 && (val == other.val) && (rowDim == other.rowDim) && (colDim == other.colDim) );
00071 }
00072
00073 bool operator != (MatRecord const &other) const {
00074 return (!((*this) == other));
00075 }
00076
00077 bool operator < (MatRecord const &other) const {
00078 if(rowIdx < other.rowIdx) {
00079 return true;
00080 }else if(rowIdx == other.rowIdx) {
00081 if(rowDim < other.rowDim) {
00082 return true;
00083 }else if(rowDim == other.rowDim) {
00084 if(colIdx < other.colIdx) {
00085 return true;
00086 }else if (colIdx == other.colIdx) {
00087 if(colDim < other.colDim) {
00088 return true;
00089 }else if(colDim == other.colDim) {
00090 return (val < other.val);
00091 }else {
00092 return false;
00093 }
00094 }else {
00095 return false;
00096 }
00097 }else {
00098 return false;
00099 }
00100 }else {
00101 return false;
00102 }
00103 }
00104
00105 bool operator > (MatRecord const &other) const {
00106 return ( (!((*this) < other)) && ((*this) != other) );
00107 }
00108
00109 bool operator <= (MatRecord const &other) const {
00110 return ( ((*this) < other) || ((*this) == other) );
00111 }
00112
00113 bool operator >= (MatRecord const &other) const {
00114 return (!((*this) < other)) ;
00115 }
00117 };
00118
00119 }
00120
00121 #endif
00122