Reworking vector class with core funtionality

This commit is contained in:
2025-09-08 20:24:51 +02:00
parent 417afb32b5
commit 0bd96dd219
7 changed files with 236 additions and 106 deletions
+21 -31
View File
@@ -1,45 +1,35 @@
#include "./utils/utils.h"
#include <vector>
#include <iostream>
int main(int argc, char const *argv[])
{
utils::Vd vect1, vect2;
//vect1.linspace(1, 3.14159, 3);
vect1.fill(3, 1);
vect1.print();
//std::cout << vect[1] << std::endl;
utils::Vf vect1(3,1), vect2(3,1), vect3(3,1), addition_test(3,7), subtract_test(3,-2);
//###########################################
//# VECTOR TYPE TEST #
//# Addition Test #
//###########################################
vect1.inplace_add(vect2);
vect3 = vect1.add(vect2).add(vect1) + vect2;
vect3 += vect2;
if (vect3 != addition_test){
throw std::runtime_error("Addition Test -> Failed");}
utils::Md matr1, matr2, matr3;
matr1.fill(4,4, 1);
matr1.print();
vect2 = matr1.vecmult(vect1);
vect2.print();
/*
matr2 = matr1.inverse("Gauss-Jordan");
matr3 = matr1.matmult(matr2);
//
matr1.print();
std::cout << "======" << std::endl;
matr2.print();
std::cout << "======" << std::endl;
matr3.print();
std::cout << "======" << std::endl;
matr1.matmult(matr2).print();
//###########################################
//# VECTOR TYPE TEST #
//# Subtract Test #
//###########################################
vect1.inplace_vec_subtract(vect2);
vect3 = vect1.vec_subtract(vect2).vec_subtract(vect1) - vect2;
vect3.print();
vect3 = vect3.add(2);
vect3.print();
if (vect3 != subtract_test){
throw std::runtime_error("Subtract Test -> Failed");}
std::cout << "---------" << std::endl;
utils::Md matr4(2,3,2);
vect2 = matr4.vecmult(vect1);
matr4.inplace_transpose();
matr4.transpose();
//result.print();
*/
return 0;