use crate::error::IError;
use crate::error::IResult;
use crate::matrix::Matrix;
use crate::num::number::Zero;
pub fn points<T, R>(
mut f: impl FnMut(usize, usize) -> (T, R),
row: usize,
col: usize,
) -> Vec<(T, R)> {
let mut ps = Vec::with_capacity(row * col);
for r in 1..=row {
for c in 1..=col {
ps.push(f(r, c))
}
}
ps
}
pub fn horizontal_concat<T>(mat: &Matrix<T>, rhs: &Matrix<T>) -> IResult<Matrix<T>>
where
T: Clone + Zero,
{
if mat.row() != rhs.row() {
Err(IError::IncompatibleShape(
(mat.row(), rhs.column()),
rhs.dim,
))
} else {
let mut hmat = Matrix::zeros(mat.row(), mat.column() + rhs.column())?;
for r in 1..=mat.row() {
for c1 in 1..=mat.column() {
hmat.set_element(r, c1, mat.get_element(r, c1)?.clone())?;
}
for c2 in 1..=rhs.column() {
hmat.set_element(r, mat.column() + c2, rhs.get_element(r, c2)?.clone())?;
}
}
Ok(hmat)
}
}
pub fn vertical_concat<T>(mat: &Matrix<T>, rhs: &Matrix<T>) -> IResult<Matrix<T>>
where
T: Clone,
{
Matrix::create(
mat.row() + rhs.row(),
mat.column(),
[&mat.inner[..], &rhs.inner[..]].concat(),
)
}
pub fn eigen_values() {
todo!()
}
pub fn linear_solve() {
todo!()
}
pub fn eigen_system() {
todo!()
}