Skip to content

Commit a520d52

Browse files
author
Jason Ramapuram
committed
add rows and cols (note the plural) to parallel af mainline
1 parent 7c2e386 commit a520d52

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/index.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ pub fn row(input: &Array, row_num: u64) -> Result<Array, AfError> {
125125
,Seq::new(0.0, dims[1] as f64 - 1.0, 1.0)])
126126
}
127127

128+
pub fn rows(input: &Array, first: u64, last: u64) -> Result<Array, AfError> {
129+
let dims_err = input.dims();
130+
let dims = match dims_err {
131+
Ok(dim) => dim.clone(),
132+
Err(e) => panic!("Error unwrapping dims in row(): {}", e),
133+
};
134+
135+
index(input, &[Seq::new(first as f64, last as f64, 1.0)
136+
,Seq::new(0.0, dims[1] as f64 - 1.0, 1.0)])
137+
}
138+
128139
pub fn col(input: &Array, col_num: u64) -> Result<Array, AfError> {
129140
let dims_err = input.dims();
130141
let dims = match dims_err {
@@ -136,6 +147,17 @@ pub fn col(input: &Array, col_num: u64) -> Result<Array, AfError> {
136147
,Seq::new(col_num as f64, col_num as f64, 1.0)])
137148
}
138149

150+
pub fn cols(input: &Array, first: u64, last: u64) -> Result<Array, AfError> {
151+
let dims_err = input.dims();
152+
let dims = match dims_err {
153+
Ok(dim) => dim.clone(),
154+
Err(e) => panic!("Error unwrapping dims in row(): {}", e),
155+
};
156+
157+
index(input, &[Seq::new(0.0, dims[0] as f64 - 1.0, 1.0)
158+
,Seq::new(first as f64, last as f64, 1.0)])
159+
}
160+
139161
pub fn lookup(input: &Array, indices: &Array, seq_dim: i32) -> Result<Array, AfError> {
140162
unsafe {
141163
let mut temp: i64 = 0;

0 commit comments

Comments
 (0)