elemental/standard/
cos.rs1use crate::Matrix;
4use crate::error::*;
5
6use super::StdFunc;
7
8#[derive(Clone)]
9pub struct Cos;
10
11impl Cos {
12 pub fn evalpure(matrix: &Matrix) -> Matrix {
14 let mut output = Vec::new();
15 let rows = matrix.rows();
16 let cols = matrix.cols();
17
18 for v in matrix.vals() {
19 output.push(v.cos());
20 }
21
22 Matrix::new(
23 rows,
24 cols,
25 output,
26 )
27 }
28}
29
30impl StdFunc for Cos {
31 fn eval(&self, args: Vec<Matrix>) -> Matrix {
32 if args.len() != 1 {
33 throw(WrongNumberOfArgs);
34 return Matrix::new(0, 0, Vec::new());
35 }
36
37 Self::evalpure(&args[0])
38 }
39}