Struct rustml::octave::OctaveScriptBuilder
[−]
[src]
pub struct OctaveScriptBuilder { // some fields omitted }
Methods
impl OctaveScriptBuilder
fn add(&self, s: &str) -> OctaveScriptBuilder
Adds the string to the Octave script.
At the end of the line a semicolon is appended.
fn add_columns<T: Display + Copy>(&self, s: &str, m: &Matrix<T>) -> OctaveScriptBuilder
Adds the string to the Octave script.
At the end of the line a semicolon is appended.
If the string contains a dollar sign followed by a number i
(e.g. $1
or $12
)
this placeholder will be replaced by the column if matrix m
at column
i-1
(i.e. $1 is replaced by the first column of m
).
Example
use rustml::octave::*; use rustml::matrix::Matrix; let m = mat![ 1, 2, 3; 4, 5, 6 ]; let s = builder().add_columns("x = $1; y = $2", &m); assert_eq!( s.to_string(), "1;\nx = [1,4]; y = [2,5];\n" );
fn add_vector<T: Display>(&self, s: &str, vals: &[T]) -> OctaveScriptBuilder
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 a vector
containing the elements of vals
.
Example
use rustml::octave::*; let s = builder().add_vector("x = $$", &[1, 2, 3]); assert_eq!( s.to_string(), "1;\nx = [1,2,3];\n" );
fn add_vector_iter<T: Display, I: Iterator<Item=T>>(&self, s: &str, vals: I) -> OctaveScriptBuilder
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 a vector
containing the elements of iterator vals
.
Example
use rustml::octave::*; let v = vec![1, 2, 3]; let s = builder().add_vector_iter("x = $$", v.iter()); assert_eq!( s.to_string(), "1;\nx = [1,2,3];\n" );
fn add_matrix<T: Display + Clone>(&self, t: &str, m: &Matrix<T>) -> OctaveScriptBuilder
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
use rustml::octave::*; use rustml::*; let m = mat![1, 2, 3; 4, 5, 6]; let s = builder().add_matrix("x = $$", &m); assert_eq!( s.to_string(), "1;\nx = [1,2,3;4,5,6];\n" );
fn add_values<T: Display>(&self, s: &str, vals: &[T]) -> OctaveScriptBuilder
Adds the string to the Octave script.
At the end of the line a semicolon is appended.
If the string contains a dollar sign followed by a number i
(e.g. $1
or $12
)
this placeholder will be replaced by the value that is stored in the vector
vals
at index i-1
.
Example
use rustml::octave::*; let s = builder().add_values("x = $1 + $2", &[5, 3]); assert_eq!( s.to_string(), "1;\nx = 5 + 3;\n" );