Started Loss, done softmax, up to p.125

I've implemented alot of support functions that needs to be refactored, optimised and tested; mean.h, exponential.h, matdiv.h matsum.h matsubtract.h. Maybe we need to have a look at if matdiv/matmul should be in the same. Same with matadd/matsubtract and if some of it should be in matvec.h.
This commit is contained in:
2025-10-05 19:45:37 +02:00
parent 1b59713565
commit ea359f3b09
18 changed files with 407 additions and 56 deletions
+39
View File
@@ -0,0 +1,39 @@
#ifndef _matsum_n_
#define _matsum_n_
#include "./utils/vector.h"
#include "./utils/matrix.h"
#include "./core/omp_config.h"
namespace numerics{
template <typename T>
utils::Vector<T> matsum(utils::Matrix<T>& A, std::string method) {
utils::Vector<T> b;
if (method == "row"){
b.resize(A.cols(), T{0});
for (uint64_t i = 0; i < A.cols(); ++i){
for (uint64_t j = 0; j < A.rows(); ++j){
b[i] += A(j, i);
}
}
}else if (method == "col"){
b.resize(A.rows(), T{0});
for (uint64_t i = 0; i < A.cols(); ++i){
for (uint64_t j = 0; j < A.rows(); ++j){
b[j] += A(j, i);
}
}
}else{
throw std::runtime_error("matsum: choose sum by: 'row' or 'col'");
}
return b;
}
} // namespace numerics
#endif // _matadd_n_