runPosIC, VelIC, AccIC numerically correct

This commit is contained in:
Aik-Siong Koh
2023-06-24 23:08:29 -06:00
parent 371b13a9e0
commit c30ee64b89
110 changed files with 2171 additions and 129 deletions

View File

@@ -17,7 +17,10 @@ namespace MbD {
std::shared_ptr<SparseRow<double>> timesconditionedWithTol(double scaling, double tol);
std::shared_ptr<SparseRow<double>> conditionedWithTol(double tol);
void atiplusFullRow(int j, std::shared_ptr<FullRow<T>> fullRow);
void atiminusFullRow(int j, std::shared_ptr<FullRow<T>> fullRow);
void atiplusFullRowtimes(int j, std::shared_ptr<FullRow<T>> fullRow, double factor);
T timesFullColumn(std::shared_ptr<FullColumn<T>> fullCol);
};
using SpRowDsptr = std::shared_ptr<SparseRow<double>>;
template<>
@@ -51,6 +54,14 @@ namespace MbD {
}
}
template<typename T>
inline void SparseRow<T>::atiminusFullRow(int j, std::shared_ptr<FullRow<T>> fullRow)
{
for (int jj = 0; jj < fullRow->size(); jj++)
{
(*this)[j + jj] -= fullRow->at(jj);
}
}
template<typename T>
inline void SparseRow<T>::atiplusFullRowtimes(int j, std::shared_ptr<FullRow<T>> fullRow, double factor)
{
for (int jj = 0; jj < fullRow->size(); jj++)
@@ -58,5 +69,14 @@ namespace MbD {
(*this)[j + jj] += fullRow->at(jj) * factor;
}
}
template<typename T>
inline T SparseRow<T>::timesFullColumn(std::shared_ptr<FullColumn<T>> fullCol)
{
T sum = 0.0;
for (auto const& keyValue : *this) {
sum += fullCol->at(keyValue.first) * keyValue.second;
}
return sum;
}
}