Restore most of @oleglite Row/Col implementations lost during the last merge.
This commit is contained in:
parent
bfd97beffe
commit
d15211737a
|
@ -454,28 +454,23 @@ macro_rules! dmat_impl(
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn set_col(&mut self, col_id: usize, v: $dvec<N>) {
|
||||
fn set_col(&mut self, col_id: usize, col: $dvec<N>) {
|
||||
assert!(col_id < self.ncols);
|
||||
assert!(self.nrows == v.len());
|
||||
assert!(col.len() == self.nrows);
|
||||
|
||||
for (i, e) in v[..].iter().enumerate() {
|
||||
for row_id in 0 .. self.nrows {
|
||||
unsafe {
|
||||
self.unsafe_set((i, col_id), *e);
|
||||
self.unsafe_set((row_id, col_id), col.unsafe_at(row_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn col(&self, col_id: usize) -> $dvec<N> {
|
||||
let mut res: $dvec<N> = unsafe {
|
||||
$dvec::new_uninitialized(self.nrows)
|
||||
};
|
||||
assert!(col_id < self.ncols);
|
||||
|
||||
for (row_id, e) in res[..].iter_mut().enumerate() {
|
||||
*e = unsafe { self.unsafe_at((row_id, col_id)) };
|
||||
}
|
||||
|
||||
res
|
||||
let start = self.offset(0, col_id);
|
||||
let stop = self.offset(self.nrows, col_id);
|
||||
$dvec::from_slice(self.nrows, &self.mij[start .. stop])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,28 +496,31 @@ macro_rules! dmat_impl(
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn set_row(&mut self, row_id: usize, v: $dvec<N>) {
|
||||
fn set_row(&mut self, row_id: usize, row: $dvec<N>) {
|
||||
assert!(row_id < self.nrows);
|
||||
assert!(self.ncols == v.len());
|
||||
assert!(row.len() == self.ncols);
|
||||
|
||||
for (i, e) in v[..].iter().enumerate() {
|
||||
for col_id in 0 .. self.ncols {
|
||||
unsafe {
|
||||
self.unsafe_set((row_id, i), *e);
|
||||
self.unsafe_set((row_id, col_id), row.unsafe_at(col_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn row(&self, row_id: usize) -> $dvec<N> {
|
||||
let mut res: $dvec<N> = unsafe {
|
||||
assert!(row_id < self.nrows);
|
||||
|
||||
let mut slice : $dvec<N> = unsafe {
|
||||
$dvec::new_uninitialized(self.ncols)
|
||||
};
|
||||
|
||||
for (col_id, e) in res[..].iter_mut().enumerate() {
|
||||
*e = unsafe { self.unsafe_at((row_id, col_id)) };
|
||||
for col_id in 0 .. self.ncols {
|
||||
unsafe {
|
||||
slice.unsafe_set(col_id, self.unsafe_at((row_id, col_id)));
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
slice
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue