/*************************************************************************** * Copyright (c) 2023 Ondsel, Inc. * * * * This file is part of OndselSolver. * * * * See LICENSE file for details about copyright. * ***************************************************************************/ #include #include "FullColumn.h" #include "FullRow.h" #include "FullMatrix.h" namespace MbD { template FColsptr FullColumn::plusFullColumn(FColsptr fullCol) { int n = (int) this->size(); auto answer = std::make_shared>(n); for (int i = 0; i < n; i++) { answer->at(i) = this->at(i) + fullCol->at(i); } return answer; } template FColsptr FullColumn::minusFullColumn(FColsptr fullCol) { int n = (int) this->size(); auto answer = std::make_shared>(n); for (int i = 0; i < n; i++) { answer->at(i) = this->at(i) - fullCol->at(i); } return answer; } template<> FColDsptr FullColumn::times(double a) { int n = (int)this->size(); auto answer = std::make_shared>(n); for (int i = 0; i < n; i++) { answer->at(i) = this->at(i) * a; } return answer; } template FColsptr FullColumn::times(T a) { assert(false); auto answer = std::make_shared>(); return answer; } template FColsptr FullColumn::negated() { return this->times(-1.0); } template void FullColumn::atiputFullColumn(int i, FColsptr fullCol) { for (int ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) = fullCol->at(ii); } } template void FullColumn::atiplusFullColumn(int i, FColsptr fullCol) { for (int ii = 0; ii < fullCol->size(); ii++) { this->at(i + ii) += fullCol->at(ii); } } template void FullColumn::equalSelfPlusFullColumnAt(FColsptr fullCol, int ii) { //self is subcolumn of fullCol for (int i = 0; i < this->size(); i++) { this->at(i) += fullCol->at(ii + i); } } template void FullColumn::atiminusFullColumn(int i1, FColsptr fullCol) { for (int ii = 0; ii < fullCol->size(); ii++) { int i = i1 + ii; this->at(i) -= fullCol->at(ii); } } template void FullColumn::equalFullColumnAt(FColsptr fullCol, int i) { this->equalArrayAt(fullCol, i); //for (int ii = 0; ii < this->size(); ii++) //{ // this->at(ii) = fullCol->at(i + ii); //} } template<> FColDsptr FullColumn::copy() { auto n = (int) this->size(); auto answer = std::make_shared>(n); for (int i = 0; i < n; i++) { answer->at(i) = this->at(i); } return answer; } template FRowsptr FullColumn::transpose() { return std::make_shared>(*this); } template void FullColumn::atiplusFullColumntimes(int i1, FColsptr fullCol, T factor) { for (int ii = 0; ii < fullCol->size(); ii++) { int i = i1 + ii; this->at(i) += fullCol->at(ii) * factor; } } template T FullColumn::transposeTimesFullColumn(const FColsptr fullCol) { return this->dot(fullCol); } template void FullColumn::equalSelfPlusFullColumntimes(FColsptr fullCol, T factor) { this->equalSelfPlusFullVectortimes(fullCol, factor); } template FColsptr FullColumn::cross(FColsptr fullCol) { auto a0 = this->at(0); auto a1 = this->at(1); auto a2 = this->at(2); auto b0 = fullCol->at(0); auto b1 = fullCol->at(1); auto b2 = fullCol->at(2); auto answer = std::make_shared>(3); answer->atiput(0, a1 * b2 - (a2 * b1)); answer->atiput(1, a2 * b0 - (a0 * b2)); answer->atiput(2, a0 * b1 - (a1 * b0)); return answer; } //template<> //inline std::shared_ptr> FullColumn::simplified() //{ // auto n = this->size(); // auto answer = std::make_shared>(n); // for (int i = 0; i < n; i++) // { // auto func = this->at(i); // answer->at(i) = func->simplified(func); // } // return answer; //} template FColsptr FullColumn::simplified() { // assert(false); return FColsptr(); } // instantiate on purpose to make visible in library api: template class FullColumn; template class FullColumn; }