-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perforated effective openness geometry renamed to Type. Also, solver …
…is simplified so it will use const matrix and vector on the input.
- Loading branch information
Showing
24 changed files
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,64 @@ | ||
#include <stdexcept> | ||
#include <cassert> | ||
#include <numeric> | ||
#include <algorithm> | ||
#include <cmath> | ||
|
||
#include "LinearSolver.hpp" | ||
#include "SquareMatrix.hpp" | ||
|
||
#include <cmath> | ||
|
||
|
||
namespace FenestrationCommon | ||
{ | ||
std::vector<double> solveSystem(SquareMatrix t_MatrixA, std::vector<double> & t_VectorB) | ||
std::vector<double> solveSystem(const SquareMatrix & t_MatrixA, | ||
const std::vector<double> & t_VectorB) | ||
{ | ||
if(t_MatrixA.size() != t_VectorB.size()) | ||
{ | ||
throw std::runtime_error( | ||
"Matrix and vector for system of linear equations are not same size."); | ||
"Matrix and vector for system of linear equations are not the same size."); | ||
} | ||
|
||
std::vector<size_t> index = t_MatrixA.makeUpperTriangular(); | ||
// Make a copy of t_VectorB to work with | ||
std::vector<double> resultVector = t_VectorB; | ||
|
||
const int size = int(t_MatrixA.size()); | ||
// Make a copy of t_MatrixA to work with (if necessary, depending on makeUpperTriangular | ||
// implementation) | ||
SquareMatrix matrixA = t_MatrixA; | ||
|
||
std::vector<size_t> index = matrixA.makeUpperTriangular(); | ||
const size_t size = matrixA.size(); | ||
|
||
int ii = -1; | ||
for(int i = 0; i < size; ++i) | ||
for(size_t i = 0; i < size; ++i) | ||
{ | ||
size_t ll = index[i]; | ||
double sum = t_VectorB[ll]; | ||
t_VectorB[ll] = t_VectorB[i]; | ||
std::swap(resultVector[ll], resultVector[i]); | ||
double sum = resultVector[i]; | ||
if(ii != -1) | ||
{ | ||
for(int j = ii; j <= i - 1; ++j) | ||
for(size_t j = ii; j < i; ++j) | ||
{ | ||
sum -= t_MatrixA(i, j) * t_VectorB[j]; | ||
} // j | ||
sum -= matrixA(i, j) * resultVector[j]; | ||
} | ||
} | ||
else if(sum != 0.0) | ||
{ | ||
ii = int(i); | ||
ii = static_cast<int>(i); | ||
} | ||
t_VectorB[i] = sum; | ||
} // i | ||
resultVector[i] = sum; | ||
} | ||
|
||
for(int i = (size - 1); i >= 0; --i) | ||
for(int i = static_cast<int>(size) - 1; i >= 0; --i) | ||
{ | ||
double sum = t_VectorB[i]; | ||
for(int j = i + 1; j < size; ++j) | ||
double sum = resultVector[i]; | ||
for(size_t j = i + 1; j < size; ++j) | ||
{ | ||
sum -= t_MatrixA(i, j) * t_VectorB[j]; | ||
} // j | ||
t_VectorB[i] = sum / t_MatrixA(i, i); | ||
} // i | ||
sum -= matrixA(i, j) * resultVector[j]; | ||
} | ||
resultVector[i] = sum / matrixA(i, i); | ||
} | ||
|
||
return t_VectorB; | ||
return resultVector; | ||
} | ||
|
||
} // namespace FenestrationCommon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.