Struct Frontend

Source
pub struct Frontend { /* private fields */ }
Expand description

A frontend structure.

The frontend contains methods which operate on matrices or calculate functions for the matrices. Backend methods are called by the frontend to operate the matrices. The frontend is high-level layer that can be directly used by programmer or a Matrix structure.

Implementations§

Source§

impl Frontend

Source

pub fn new() -> Result<Frontend>

Creates a frontend with a default backend.

This method also automatically initializes a default backend if the default backend is uninitialized.

Examples found in repository?
examples/mul.rs (line 63)
24fn main()
25{
26    let args: Vec<String> = env::args().collect();
27    let n: usize = match args.get(1) {
28        Some(s) => {
29            match s.parse::<usize>() {
30                Ok(tmp_n) => tmp_n,
31                Err(err) => {
32                    eprintln!("{}", err);
33                    exit(1);
34                },
35            }
36        },
37        None => 100,
38    };
39    let m: usize = match args.get(2) {
40        Some(s) => {
41            match s.parse::<usize>() {
42                Ok(tmp_m) => tmp_m,
43                Err(err) => {
44                    eprintln!("{}", err);
45                    exit(1);
46                },
47            }
48        },
49        None => 100,
50    };
51    let l: usize = match args.get(3) {
52        Some(s) => {
53            match s.parse::<usize>() {
54                Ok(tmp_l) => tmp_l,
55                Err(err) => {
56                    eprintln!("{}", err);
57                    exit(1);
58                },
59            }
60        },
61        None => 100,
62    };
63    let frontend = match Frontend::new() {
64        Ok(tmp_frontend) => tmp_frontend,
65        Err(err) => {
66            eprintln!("{}", err);
67            exit(1);
68        },
69    };
70    println!("backend: {}", frontend.backend().name());
71    let a = create_matrix(n, l);
72    let b = create_matrix(l, m);
73    let now = Instant::now();
74    let c = a * b;
75    let duration = now.elapsed();
76    let elems = c.elems();
77    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
78    println!("sum: {}", sum);
79    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
80    match finalize_default_backend() {
81        Ok(()) => (),
82        Err(err) => {
83            eprintln!("{}", err);
84            exit(1);
85        },
86    }
87}
More examples
Hide additional examples
examples/mul_bt.rs (line 63)
24fn main()
25{
26    let args: Vec<String> = env::args().collect();
27    let n: usize = match args.get(1) {
28        Some(s) => {
29            match s.parse::<usize>() {
30                Ok(tmp_n) => tmp_n,
31                Err(err) => {
32                    eprintln!("{}", err);
33                    exit(1);
34                },
35            }
36        },
37        None => 100,
38    };
39    let m: usize = match args.get(2) {
40        Some(s) => {
41            match s.parse::<usize>() {
42                Ok(tmp_m) => tmp_m,
43                Err(err) => {
44                    eprintln!("{}", err);
45                    exit(1);
46                },
47            }
48        },
49        None => 100,
50    };
51    let l: usize = match args.get(3) {
52        Some(s) => {
53            match s.parse::<usize>() {
54                Ok(tmp_l) => tmp_l,
55                Err(err) => {
56                    eprintln!("{}", err);
57                    exit(1);
58                },
59            }
60        },
61        None => 100,
62    };
63    let frontend = match Frontend::new() {
64        Ok(tmp_frontend) => tmp_frontend,
65        Err(err) => {
66            eprintln!("{}", err);
67            exit(1);
68        },
69    };
70    println!("backend: {}", frontend.backend().name());
71    let a = create_matrix(n, l);
72    let b = create_matrix(m, l);
73    let now = Instant::now();
74    let c = a * b.transpose();
75    let duration = now.elapsed();
76    let elems = c.elems();
77    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
78    println!("sum: {}", sum);
79    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
80    match finalize_default_backend() {
81        Ok(()) => (),
82        Err(err) => {
83            eprintln!("{}", err);
84            exit(1);
85        },
86    }
87}
examples/mad.rs (line 68)
29fn main()
30{
31    let args: Vec<String> = env::args().collect();
32    let n: usize = match args.get(1) {
33        Some(s) => {
34            match s.parse::<usize>() {
35                Ok(tmp_n) => tmp_n,
36                Err(err) => {
37                    eprintln!("{}", err);
38                    exit(1);
39                },
40            }
41        },
42        None => 100,
43    };
44    let m: usize = match args.get(2) {
45        Some(s) => {
46            match s.parse::<usize>() {
47                Ok(tmp_m) => tmp_m,
48                Err(err) => {
49                    eprintln!("{}", err);
50                    exit(1);
51                },
52            }
53        },
54        None => 100,
55    };
56    let l: usize = match args.get(3) {
57        Some(s) => {
58            match s.parse::<usize>() {
59                Ok(tmp_l) => tmp_l,
60                Err(err) => {
61                    eprintln!("{}", err);
62                    exit(1);
63                },
64            }
65        },
66        None => 100,
67    };
68    let frontend = match Frontend::new() {
69        Ok(tmp_frontend) => tmp_frontend,
70        Err(err) => {
71            eprintln!("{}", err);
72            exit(1);
73        },
74    };
75    println!("backend: {}", frontend.backend().name());
76    let a = create_matrix(n, l, false);
77    let b = create_matrix(l, m, false);
78    let c = create_matrix(n, m, true);
79    let now = Instant::now();
80    let d = a * b + c;
81    let duration = now.elapsed();
82    let elems = d.elems();
83    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
84    println!("sum: {}", sum);
85    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
86    match finalize_default_backend() {
87        Ok(()) => (),
88        Err(err) => {
89            eprintln!("{}", err);
90            exit(1);
91        },
92    }
93}
Source

pub fn new_with_backend(backend: Arc<dyn Backend>) -> Frontend

Creates a frotend with the backend.

Source

pub fn backend(&self) -> Arc<dyn Backend>

Returns the backend.

Examples found in repository?
examples/mul.rs (line 70)
24fn main()
25{
26    let args: Vec<String> = env::args().collect();
27    let n: usize = match args.get(1) {
28        Some(s) => {
29            match s.parse::<usize>() {
30                Ok(tmp_n) => tmp_n,
31                Err(err) => {
32                    eprintln!("{}", err);
33                    exit(1);
34                },
35            }
36        },
37        None => 100,
38    };
39    let m: usize = match args.get(2) {
40        Some(s) => {
41            match s.parse::<usize>() {
42                Ok(tmp_m) => tmp_m,
43                Err(err) => {
44                    eprintln!("{}", err);
45                    exit(1);
46                },
47            }
48        },
49        None => 100,
50    };
51    let l: usize = match args.get(3) {
52        Some(s) => {
53            match s.parse::<usize>() {
54                Ok(tmp_l) => tmp_l,
55                Err(err) => {
56                    eprintln!("{}", err);
57                    exit(1);
58                },
59            }
60        },
61        None => 100,
62    };
63    let frontend = match Frontend::new() {
64        Ok(tmp_frontend) => tmp_frontend,
65        Err(err) => {
66            eprintln!("{}", err);
67            exit(1);
68        },
69    };
70    println!("backend: {}", frontend.backend().name());
71    let a = create_matrix(n, l);
72    let b = create_matrix(l, m);
73    let now = Instant::now();
74    let c = a * b;
75    let duration = now.elapsed();
76    let elems = c.elems();
77    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
78    println!("sum: {}", sum);
79    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
80    match finalize_default_backend() {
81        Ok(()) => (),
82        Err(err) => {
83            eprintln!("{}", err);
84            exit(1);
85        },
86    }
87}
More examples
Hide additional examples
examples/mul_bt.rs (line 70)
24fn main()
25{
26    let args: Vec<String> = env::args().collect();
27    let n: usize = match args.get(1) {
28        Some(s) => {
29            match s.parse::<usize>() {
30                Ok(tmp_n) => tmp_n,
31                Err(err) => {
32                    eprintln!("{}", err);
33                    exit(1);
34                },
35            }
36        },
37        None => 100,
38    };
39    let m: usize = match args.get(2) {
40        Some(s) => {
41            match s.parse::<usize>() {
42                Ok(tmp_m) => tmp_m,
43                Err(err) => {
44                    eprintln!("{}", err);
45                    exit(1);
46                },
47            }
48        },
49        None => 100,
50    };
51    let l: usize = match args.get(3) {
52        Some(s) => {
53            match s.parse::<usize>() {
54                Ok(tmp_l) => tmp_l,
55                Err(err) => {
56                    eprintln!("{}", err);
57                    exit(1);
58                },
59            }
60        },
61        None => 100,
62    };
63    let frontend = match Frontend::new() {
64        Ok(tmp_frontend) => tmp_frontend,
65        Err(err) => {
66            eprintln!("{}", err);
67            exit(1);
68        },
69    };
70    println!("backend: {}", frontend.backend().name());
71    let a = create_matrix(n, l);
72    let b = create_matrix(m, l);
73    let now = Instant::now();
74    let c = a * b.transpose();
75    let duration = now.elapsed();
76    let elems = c.elems();
77    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
78    println!("sum: {}", sum);
79    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
80    match finalize_default_backend() {
81        Ok(()) => (),
82        Err(err) => {
83            eprintln!("{}", err);
84            exit(1);
85        },
86    }
87}
examples/mad.rs (line 75)
29fn main()
30{
31    let args: Vec<String> = env::args().collect();
32    let n: usize = match args.get(1) {
33        Some(s) => {
34            match s.parse::<usize>() {
35                Ok(tmp_n) => tmp_n,
36                Err(err) => {
37                    eprintln!("{}", err);
38                    exit(1);
39                },
40            }
41        },
42        None => 100,
43    };
44    let m: usize = match args.get(2) {
45        Some(s) => {
46            match s.parse::<usize>() {
47                Ok(tmp_m) => tmp_m,
48                Err(err) => {
49                    eprintln!("{}", err);
50                    exit(1);
51                },
52            }
53        },
54        None => 100,
55    };
56    let l: usize = match args.get(3) {
57        Some(s) => {
58            match s.parse::<usize>() {
59                Ok(tmp_l) => tmp_l,
60                Err(err) => {
61                    eprintln!("{}", err);
62                    exit(1);
63                },
64            }
65        },
66        None => 100,
67    };
68    let frontend = match Frontend::new() {
69        Ok(tmp_frontend) => tmp_frontend,
70        Err(err) => {
71            eprintln!("{}", err);
72            exit(1);
73        },
74    };
75    println!("backend: {}", frontend.backend().name());
76    let a = create_matrix(n, l, false);
77    let b = create_matrix(l, m, false);
78    let c = create_matrix(n, m, true);
79    let now = Instant::now();
80    let d = a * b + c;
81    let duration = now.elapsed();
82    let elems = d.elems();
83    let sum = elems.iter().fold(0.0f32, |x, y| x + y);
84    println!("sum: {}", sum);
85    println!("time: {}.{:06}", duration.as_secs(), duration.as_micros() % 1000000);
86    match finalize_default_backend() {
87        Ok(()) => (),
88        Err(err) => {
89            eprintln!("{}", err);
90            exit(1);
91        },
92    }
93}
Source

pub unsafe fn create_matrix( &self, row_count: usize, col_count: usize, ) -> Result<Matrix>

Creates a matrix with unset elements.

Source

pub fn create_matrix_and_set_zeros( &self, row_count: usize, col_count: usize, ) -> Result<Matrix>

Creates a matrix and sets the matrix elements on zeros.

Source

pub fn create_matrix_and_set_elems( &self, row_count: usize, col_count: usize, elems: &[f32], ) -> Result<Matrix>

Creates a matrix and sets the matrix elements.

Source

pub fn set_elems(&self, a: &Matrix, elems: &[f32]) -> Result<()>

Sets the matrix elements.

Source

pub fn copy(&self, a: &Matrix, b: &Matrix) -> Result<()>

Copies the a matrix to the b matrix.

This method indeed copies the a matrix array to the b matrix array.

Source

pub fn get_elems_and_transpose_flag( &self, a: &Matrix, elems: &mut [f32], is_transposed: &mut bool, ) -> Result<()>

Copies the matrix elements to the mutable slice and the transpose flag to the object that is referred by the reference.

Source

pub fn elems_and_transpose_flag(&self, a: &Matrix) -> Result<(Vec<f32>, bool)>

Returns the elements and the transpose flag of matrix.

Source

pub fn add(&self, a: &Matrix, b: &Matrix, c: &Matrix) -> Result<()>

Adds the b matrix to the a matrix and then the result is in the c matrix (C=A+B).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = matrix![
    [5.0, 6.0],
    [7.0, 8.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.add(&a, &b, &c).unwrap();
assert_eq!(vec![1.0 + 5.0, 2.0 + 6.0, 3.0 + 7.0, 4.0 + 8.0], c.elems());
Source

pub fn sub(&self, a: &Matrix, b: &Matrix, c: &Matrix) -> Result<()>

Subtracts the b matrix from the a matrix and then the result is in the c matrix (C=A-B).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = matrix![
    [5.0, 6.0],
    [7.0, 8.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.sub(&a, &b, &c).unwrap();
assert_eq!(vec![1.0 - 5.0, 2.0 - 6.0, 3.0 - 7.0, 4.0 - 8.0], c.elems());
Source

pub fn mul(&self, a: &Matrix, b: &Matrix, c: &Matrix) -> Result<()>

Multiplies the a matrix by the b matrix and then the result is in the c matrix (C=A·B).

§Examples
let a = matrix![
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0]
];
let b = matrix![
    [7.0,  8.0],
    [9.0,  10.0],
    [11.0, 12.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.mul(&a, &b, &c).unwrap();
let c11: f32 = 1.0 * 7.0 + 2.0 * 9.0 + 3.0 * 11.0;
let c12: f32 = 1.0 * 8.0 + 2.0 * 10.0 + 3.0 * 12.0;
let c21: f32 = 4.0 * 7.0 + 5.0 * 9.0 + 6.0 * 11.0;
let c22: f32 = 4.0 * 8.0 + 5.0 * 10.0 + 6.0 * 12.0;
assert_eq!(vec![c11, c12, c21, c22], c.elems());
Source

pub fn mul_elems(&self, a: &Matrix, b: &Matrix, c: &Matrix) -> Result<()>

Multiplies the a matrix elements by the b matrix elements and then the result is in the c matrix (cij=aij·bij).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = matrix![
    [5.0, 6.0],
    [7.0, 8.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.mul_elems(&a, &b, &c).unwrap();
assert_eq!(vec![1.0 * 5.0, 2.0 * 6.0, 3.0 * 7.0, 4.0 * 8.0], c.elems());
Source

pub fn div_elems(&self, a: &Matrix, b: &Matrix, c: &Matrix) -> Result<()>

Divides the a matrix elements by the b matrix elements and then the result is in the c matrix (cij=aijbij).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = matrix![
    [5.0, 6.0],
    [7.0, 8.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.div_elems(&a, &b, &c).unwrap();
let elems = c.elems();
assert!((1.0 / 5.0 - elems[0]).abs() < 0.001);
assert!((2.0 / 6.0 - elems[1]).abs() < 0.001);
assert!((3.0 / 7.0 - elems[2]).abs() < 0.001);
assert!((4.0 / 8.0 - elems[3]).abs() < 0.001);
Source

pub fn add_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Adds the b scalar to the a matrix and then the result is in the c matrix (C=A+b).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.add_for_scalar(&a, 10.5, &c).unwrap();
assert_eq!(vec![1.0 + 10.5, 2.0 + 10.5, 3.0 + 10.5, 4.0 + 10.5], c.elems());
Source

pub fn sub_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Subtracts the b scalar from the a matrix and then the result is in the c matrix (C=A-b).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.sub_for_scalar(&a, 10.5, &c).unwrap();
assert_eq!(vec![1.0 - 10.5, 2.0 - 10.5, 3.0 - 10.5, 4.0 - 10.5], c.elems());
Source

pub fn rsub_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Subtracts the a matrix from the b scalar and then the result is in the c matrix (C=b-A).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.rsub_for_scalar(&a, 10.5, &c).unwrap();
assert_eq!(vec![10.5 - 1.0, 10.5 - 2.0, 10.5 - 3.0, 10.5 - 4.0], c.elems());
Source

pub fn mul_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Multiplies the a matrix by the b scalar and then the result is in the c matrix (C=A·b).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.mul_for_scalar(&a, 10.5, &c).unwrap();
assert_eq!(vec![1.0 * 10.5, 2.0 * 10.5, 3.0 * 10.5, 4.0 * 10.5], c.elems());
Source

pub fn div_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Divides the a matrix by the b scalar and then the result is in the c matrix (C=Ab).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.div_for_scalar(&a, 10.5, &c).unwrap();
let elems = c.elems();
assert!((1.0 / 10.5 - elems[0]).abs() < 0.001);
assert!((2.0 / 10.5 - elems[1]).abs() < 0.001);
assert!((3.0 / 10.5 - elems[2]).abs() < 0.001);
assert!((4.0 / 10.5 - elems[3]).abs() < 0.001);
Source

pub fn rdiv_for_scalar(&self, a: &Matrix, b: f32, c: &Matrix) -> Result<()>

Divides the b scalar by the a matrix elements and then the result is in the c matrix (cij=baij).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let c = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.rdiv_for_scalar(&a, 10.5, &c).unwrap();
let elems = c.elems();
assert!((10.5 / 1.0- elems[0]).abs() < 0.001);
assert!((10.5 / 2.0 - elems[1]).abs() < 0.001);
assert!((10.5 / 3.0 - elems[2]).abs() < 0.001);
assert!((10.5 / 4.0 - elems[3]).abs() < 0.001);
Source

pub fn sigmoid(&self, a: &Matrix, b: &Matrix) -> Result<()>

Calculates sigmoid function for the a matrix and then the result is in the b matrix (B=sigmoid(A)).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.sigmoid(&a, &b).unwrap();
let elems = b.elems();
assert!((1.0 / (1.0 + (-1.0f32).exp()) - elems[0]).abs() < 0.001);
assert!((1.0 / (1.0 + (-2.0f32).exp()) - elems[1]).abs() < 0.001);
assert!((1.0 / (1.0 + (-3.0f32).exp()) - elems[2]).abs() < 0.001);
assert!((1.0 / (1.0 + (-4.0f32).exp()) - elems[3]).abs() < 0.001);
Source

pub fn tanh(&self, a: &Matrix, b: &Matrix) -> Result<()>

Calculates hyperbolic tangent function for the a matrix and then the result is in the b matrix (B=tanh(A)).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.tanh(&a, &b).unwrap();
let elems = b.elems();
assert!((1.0f32.tanh() - elems[0]).abs() < 0.001);
assert!((2.0f32.tanh() - elems[1]).abs() < 0.001);
assert!((3.0f32.tanh() - elems[2]).abs() < 0.001);
assert!((4.0f32.tanh() - elems[3]).abs() < 0.001);
Source

pub fn swish(&self, a: &Matrix, b: &Matrix) -> Result<()>

Calculates swish function for the a matrix and then the result is in the b matrix (B=swish(A)).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.swish(&a, &b).unwrap();
let elems = b.elems();
assert!((1.0 / (1.0 + (-1.0f32).exp()) - elems[0]).abs() < 0.001);
assert!((2.0 / (1.0 + (-2.0f32).exp()) - elems[1]).abs() < 0.001);
assert!((3.0 / (1.0 + (-3.0f32).exp()) - elems[2]).abs() < 0.001);
assert!((4.0 / (1.0 + (-4.0f32).exp()) - elems[3]).abs() < 0.001);
Source

pub fn softmax(&self, a: &Matrix, b: &Matrix) -> Result<()>

Calculates softmax function for the a matrix and then the result is in the b matrix (B=softmax(A)).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.softmax(&a, &b).unwrap();
let elems = b.elems();
let sum1 = 1.0f32.exp() + 3.0f32.exp();
let sum2 = 2.0f32.exp() + 4.0f32.exp();
assert!((1.0f32.exp() / sum1 - elems[0]).abs() < 0.001);
assert!((2.0f32.exp() / sum2 - elems[1]).abs() < 0.001);
assert!((3.0f32.exp() / sum1 - elems[2]).abs() < 0.001);
assert!((4.0f32.exp() / sum2 - elems[3]).abs() < 0.001);
Source

pub fn sqrt(&self, a: &Matrix, b: &Matrix) -> Result<()>

Calculates square root of the a matrix and then the result is in the b matrix (B=A).

§Examples
let a = matrix![
    [1.0, 2.0],
    [3.0, 4.0]
];
let b = Matrix::new(2, 2);
let frontend = Frontend::new().unwrap();
frontend.sqrt(&a, &b).unwrap();
let elems = b.elems();
assert!((1.0f32.sqrt() - elems[0]).abs() < 0.001);
assert!((2.0f32.sqrt() - elems[1]).abs() < 0.001);
assert!((3.0f32.sqrt() - elems[2]).abs() < 0.001);
assert!((4.0f32.sqrt() - elems[3]).abs() < 0.001);
Source

pub fn really_transpose(&self, a: &Matrix, b: &Matrix) -> Result<()>

Indeed transposes the a matrix and then the result is in the b matrix (B=AT).

This method indeed transposes the a matrix without changing the transpose flag.

§Examples
let a = matrix![
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0]
];
let b = Matrix::new(3, 2);
let frontend = Frontend::new().unwrap();
frontend.really_transpose(&a, &b).unwrap();
assert_eq!(vec![1.0, 4.0, 2.0, 5.0, 3.0, 6.0], b.elems());
Source

pub fn repeat(&self, a: &Matrix, b: &Matrix) -> Result<()>

Repeats the a vector as column or a row (bij=ai or bij=aj).

§Examples
let a = matrix![
    [1.0],
    [2.0]
];
let b = Matrix::new(2, 3);
let frontend = Frontend::new().unwrap();
frontend.repeat(&a, &b).unwrap();
assert_eq!(vec![1.0, 1.0, 1.0, 2.0, 2.0, 2.0], b.elems());
let c = matrix![[1.0, 2.0, 3.0]];
let d = Matrix::new(2, 3);
let frontend = Frontend::new().unwrap();
frontend.repeat(&c, &d).unwrap();
assert_eq!(vec![1.0, 2.0, 3.0, 1.0, 2.0, 3.0], d.elems());

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.