MCPcopy Create free account
hub / github.com/daniel-e/rustml / add_matrix

Method add_matrix

src/octave.rs:167–180  ·  view source on GitHub ↗

Adds the string to the Octave script. At the end of the line a semicolon is appended. If the string contains two consecutive dollar signs (i.e. `$$`) these will be replaced by the matrix `m`. # Example ``` # #[macro_use] extern crate rustml; use rustml::octave::*; use rustml::*; # pub fn main() { let m = mat![1, 2, 3; 4, 5, 6]; let s = builder().add_matrix("x = $$", &m); assert_eq!( s.to_strin

(&self, t: &str, m: &Matrix<T>)

Source from the content-addressed store, hash-verified

165 /// # }
166 /// ```
167 pub fn add_matrix<T: fmt::Display + Clone>(&self, t: &str, m: &Matrix<T>) -> OctaveScriptBuilder {
168
169 let mut s = "[".to_string();
170
171 for (idx, r) in m.row_iter().enumerate() {
172 if idx > 0 {
173 s = s + ";";
174 }
175 s = s + &self.join(&r);
176 }
177 s = s + "]";
178
179 self.add(&t.replace("$$", &s))
180 }
181
182 /// Adds the string to the Octave script.
183 ///

Callers 4

mainFunction · 0.80
plot_mixtureFunction · 0.80
plot_nnFunction · 0.80

Calls 4

to_stringMethod · 0.80
row_iterMethod · 0.80
joinMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected