Added LinAlg.solve (to solve linear systems)

This commit is contained in:
novak_99 2021-05-30 13:11:12 -07:00
parent 3a1a85da92
commit 5a1392bdd1
5 changed files with 8 additions and 1 deletions

View File

@ -34,7 +34,7 @@ class AutoEncoder{
void forwardPass();
std::vector<std::vector<double>> inputSet;
std::vector<std::vector<double>> y_hat; // This is your latent representation
std::vector<std::vector<double>> y_hat;
std::vector<std::vector<double>> weights1;
std::vector<std::vector<double>> weights2;

View File

@ -593,6 +593,10 @@ namespace MLPP{
return a;
}
std::vector<double> LinAlg::solve(std::vector<std::vector<double>> A, std::vector<double> b){
return mat_vec_mult(inverse(A), b);
}
void LinAlg::printMatrix(std::vector<std::vector<double>> A){
for(int i = 0; i < A.size(); i++){
for(int j = 0; j < A[i].size(); j++){

View File

@ -83,6 +83,8 @@ namespace MLPP{
double sum_elements(std::vector<std::vector<double>> A);
std::vector<double> flatten(std::vector<std::vector<double>> A);
std::vector<double> solve(std::vector<std::vector<double>> A, std::vector<double> b);
void printMatrix(std::vector<std::vector<double>> A);

Binary file not shown.

View File

@ -366,6 +366,7 @@ int main() {
// alg.printMatrix(alg.diag({1,2,3,4,5}));
// alg.printMatrix(alg.kronecker_product({{1,2,3,4,5}}, {{6,7,8,9,10}}));
// alg.printMatrix(alg.matrixPower({{5,5},{5,5}}, 2));
// alg.printVector(alg.solve({{1,1}, {1.5, 4.0}}, {2200, 5050}));
return 0;
}