This commit is contained in:
张壹 2025-02-22 11:40:45 +08:00
parent 99a2de65d6
commit 3302548788
2 changed files with 44 additions and 2 deletions

View File

@ -780,7 +780,7 @@ namespace gctl
*
* @return
*/
ArrValType module(norm_type_e n_type = L2);
ArrValType module(norm_type_e n_type = L2) const;
/**
* @brief Normalize the array to the given module value
@ -1815,7 +1815,7 @@ namespace gctl
}
template <typename ArrValType>
ArrValType array<ArrValType>::module(norm_type_e n_type)
ArrValType array<ArrValType>::module(norm_type_e n_type) const
{
static_assert(std::is_arithmetic<ArrValType>::value,
"gctl::array<T>::module(...) could only be used with an arithmetic type.");

View File

@ -245,6 +245,22 @@ namespace gctl
*/
void assign_all(MatValType in_val);
/**
* @brief
*
* @param r_id
* @param in_val
*/
void fill_row(size_t r_id, const array<MatValType> &in_arr);
/**
* @brief
*
* @param c_id
* @param in_val
*/
void fill_column(size_t c_id, const array<MatValType> &in_arr);
/**
* @brief
*
@ -790,6 +806,32 @@ namespace gctl
return;
}
template <typename MatValType>
void matrix<MatValType>::fill_row(size_t r_id, const array<MatValType> &in_arr)
{
if (r_id >= row_length) throw std::out_of_range("[gctl::matrix<T>::fill_row] Row index out of range.");
if (in_arr.size() != col_length) throw std::invalid_argument("[gctl::matrix<T>::fill_row] Invalid array length.");
for (size_t j = 0; j < col_length; j++)
{
val[r_id][j] = in_arr[j];
}
return;
}
template <typename MatValType>
void matrix<MatValType>::fill_column(size_t c_id, const array<MatValType> &in_arr)
{
if (c_id >= col_length) throw std::out_of_range("[gctl::matrix<T>::fill_column] Column index out of range.");
if (in_arr.size()!= row_length) throw std::invalid_argument("[gctl::matrix<T>::fill_column] Invalid array length.");
for (size_t i = 0; i < row_length; i++)
{
val[i][c_id] = in_arr[i];
}
return;
}
template <typename MatValType>
void matrix<MatValType>::scale(MatValType s)
{