10 #include <fei_macros.hpp>
12 #include <test_utils/test_Algebraic.hpp>
14 #include <fei_VectorSpace.hpp>
15 #include <fei_MatrixGraph_Impl2.hpp>
16 #include <fei_SparseRowGraph.hpp>
19 #define fei_file "test_Algebraic.cpp"
20 #include <fei_ErrMacros.hpp>
22 test_Algebraic::test_Algebraic(MPI_Comm comm)
27 test_Algebraic::~test_Algebraic()
31 int test_Algebraic::runtests()
34 CHK_ERR( serialtest1() );
35 CHK_ERR( serialtest2() );
45 int test_Algebraic::serialtest1()
52 vspace->defineIDTypes(1, &idType);
54 std::vector<int> rowNumbers(numRows);
55 for(i=0; i<numRows; ++i) {
59 CHK_ERR( vspace->addDOFs(idType, numRows, &rowNumbers[0]) );
61 CHK_ERR( vspace->initComplete() );
64 CHK_ERR( vspace->getGlobalIndex(idType, rowNumbers[3], index) );
70 int numDOF = vspace->getNumDegreesOfFreedom(idType, rowNumbers[3]);
76 std::vector<int> globalOffsets;
78 vspace->getGlobalIndexOffsets(globalOffsets);
80 if (globalOffsets[0] != 0) {
84 if (globalOffsets[1] != numRows) {
91 std::vector<int> rowOffsets(numRows+1);
92 std::vector<int> packedColumnIDs(numRows);
93 for(i=0; i<numRows; ++i) {
95 packedColumnIDs[i] = i;
97 rowOffsets[numRows] = numRows;
99 CHK_ERR( mgraph.initConnectivity(idType, numRows,
102 &packedColumnIDs[0]) );
104 CHK_ERR( mgraph.initComplete() );
109 int* mrowOffsets = &(localgraph->rowOffsets[0]);
110 int mnumNonzeros = localgraph->packedColumnIndices.size();
111 int* mpackedColumnIndices = &(localgraph->packedColumnIndices[0]);
113 if (mnumRows != numRows) {
117 if (mnumNonzeros != numRows) {
121 for(i=0; i<numRows; ++i) {
122 if ((mrowOffsets[i+1]-mrowOffsets[i]) != 1) {
125 if (mpackedColumnIndices[i] != packedColumnIDs[i]) {
133 int test_Algebraic::serialtest2()
140 vspace->defineIDTypes(1, &idType);
142 std::vector<int> rowNumbers(numRows);
143 for(i=0; i<numRows; ++i) {
147 CHK_ERR( vspace->addDOFs(idType, numRows, &rowNumbers[0]) );
149 CHK_ERR( vspace->initComplete() );
152 CHK_ERR( vspace->getGlobalIndex(idType, rowNumbers[3], index) );
158 int numDOF = vspace->getNumDegreesOfFreedom(idType, rowNumbers[3]);
164 std::vector<int> globalOffsets;
166 vspace->getGlobalIndexOffsets(globalOffsets);
168 if (globalOffsets[0] != 0) {
172 if (globalOffsets[1] != numRows) {
179 std::vector<int> rowLengths(numRows);
180 std::vector<int> packedColumnIDs(numRows);
181 std::vector<int*> columnIDs(numRows);
183 for(i=0; i<numRows; ++i) {
185 packedColumnIDs[i] = i;
186 columnIDs[i] = &(packedColumnIDs[i]);
189 CHK_ERR( mgraph.initConnectivity(idType, numRows,
194 CHK_ERR( mgraph.initComplete() );
199 int* mrowOffsets = &(localgraph->rowOffsets[0]);
200 int mnumNonzeros = localgraph->packedColumnIndices.size();
201 int* mpackedColumnIndices = &(localgraph->packedColumnIndices[0]);
203 if (mnumRows != numRows) {
207 if (mnumNonzeros != numRows) {
211 for(i=0; i<numRows; ++i) {
212 if ((mrowOffsets[i+1]-mrowOffsets[i]) != 1) {
215 if (mpackedColumnIndices[i] != packedColumnIDs[i]) {
223 int test_Algebraic::test1()
228 int test_Algebraic::test2()
233 int test_Algebraic::test3()
238 int test_Algebraic::test4()
std::vector< int > rowNumbers