OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Linear.hpp
Go to the documentation of this file.
1//
2// Created by Andrew Nazareth on 2/16/24.
3//
4
5#ifndef OASIS_LINEAR_HPP
6#define OASIS_LINEAR_HPP
7
8#include "Eigen/Dense"
9#include <iostream>
10#include <map>
11#include <string>
12#include <vector>
13
14#include "Expression.hpp"
15
16namespace Oasis {
17
18typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> MatrixXXD;
19typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Matrix1D;
20
26
32
39auto SolveLinearSystems(MatrixXXD& matrixA, Matrix1D& matrixb) -> Matrix1D;
40
48
59template <class u, class v>
60auto GetMapValue(std::map<u, v>& map, u key, v nextValue) -> std::pair<v, bool>
61{
62 v value;
63 bool usedNextValue = false;
64 if (auto p = map.find(key); p != map.end()) { // key is found
65 value = p->second;
66 } else { // key is not found
67 map.insert(std::make_pair(key, nextValue));
68 value = nextValue;
69 usedNextValue = true;
70 }
71 return std::make_pair(value, usedNextValue);
72}
73
74}
75
76#endif // OASIS_LINEAR_HPP
T make_pair(T... args)
Definition Add.hpp:11
Eigen::Matrix< double, Eigen::Dynamic, 1 > Matrix1D
Definition Linear.hpp:19
auto ConstructMatrices(const std::vector< std::unique_ptr< Expression > > &exprs) -> std::pair< std::pair< MatrixXXD, Matrix1D >, std::map< std::string, Eigen::Index > >
Definition Linear.cpp:37
auto GetMapValue(std::map< u, v > &map, u key, v nextValue) -> std::pair< v, bool >
Definition Linear.hpp:60
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXXD
Definition Linear.hpp:18
auto SolveLinearSystems(std::vector< std::unique_ptr< Expression > > &exprs) -> std::map< std::string, double >
Definition Linear.cpp:13