2018-09-20 20:23:31 +08:00
|
|
|
use na::{Scalar, DefaultAllocator};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
use traits::{Alloc, Dimension};
|
2018-09-20 16:50:34 +08:00
|
|
|
use aliases::{Vec, Mat};
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The `index`-th column of the matrix `m`.
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn column<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize) -> Vec<N, R>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
m.column(index).into_owned()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Sets to `x` the `index`-th column of the matrix `m`.
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn set_column<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, R>) -> Mat<N, R, C>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
let mut res = m.clone();
|
|
|
|
res.set_column(index, x);
|
|
|
|
res
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// The `index`-th row of the matrix `m`.
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn row<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize) -> Vec<N, C>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
m.row(index).into_owned().transpose()
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:18:59 +08:00
|
|
|
/// Sets to `x` the `index`-th row of the matrix `m`.
|
2018-09-20 20:23:31 +08:00
|
|
|
pub fn set_row<N: Scalar, R: Dimension, C: Dimension>(m: &Mat<N, R, C>, index: usize, x: &Vec<N, C>) -> Mat<N, R, C>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, R, C> {
|
2018-09-20 20:23:31 +08:00
|
|
|
let mut res = m.clone();
|
|
|
|
res.set_row(index, &x.transpose());
|
|
|
|
res
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|