Sync public subset from Flux
This commit is contained in:
32
include/numerics/matscalar.h
Normal file
32
include/numerics/matscalar.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "./utils/matrix.h"
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
void inplace_matscalar(utils::Matrix<T>& A, const T scalar){
|
||||
|
||||
const uint64_t rows = A.rows();
|
||||
const uint64_t cols = A.cols();
|
||||
|
||||
for (uint64_t i = 0; i < rows; ++i){
|
||||
for (uint64_t j = 0; j < cols; ++j){
|
||||
A(i,j) *= scalar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
utils::Matrix<T> matscalar(const utils::Matrix<T>& A, T scalar){
|
||||
|
||||
utils::Matrix<T> B = A;
|
||||
inplace_matscalar(B, scalar);
|
||||
return B;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
Reference in New Issue
Block a user