Skip to content

Commit

Permalink
might be some usefull stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Devarth123 committed May 30, 2022
1 parent cc6bdcb commit e8f6f64
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ml/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@ pub fn add_by_scalar64<'a>(m1: &'a MatrixStruct64, num: &f64) -> MatrixStruct64<
}
matrix
}
pub fn multiply_by_scalar32<'a>(m: &'a MatrixStruct32, num: &f32) -> MatrixStruct32<'a>{
let mut matrix = matrix_create32(m.rows, m.columns);
for i in 0..*m.rows as usize{
for j in 0..*m.columns as usize{
matrix.matrix[i][j] = m.matrix[i][j] * *num;

}
}
matrix
}
pub fn multiply_by_scalar64<'a>(m: &'a MatrixStruct64, num: &f64) -> MatrixStruct64<'a>{
let mut matrix = matrix_create64(m.rows, m.columns);
for i in 0..*m.rows as usize{
for j in 0..*m.columns as usize{
matrix.matrix[i][j] = m.matrix[i][j] * *num;

}
}
matrix
}
pub fn transpose32<'a>(m: &'a MatrixStruct32) -> MatrixStruct32<'a>{
let mut matrix = matrix_create32(m.columns, m.rows);
for i in 0..*m.rows as usize{
Expand Down

0 comments on commit e8f6f64

Please sign in to comment.