Struct OctaveScriptBuilder

Source
pub struct OctaveScriptBuilder { /* private fields */ }

Implementations§

Source§

impl OctaveScriptBuilder

Source

pub fn add(&self, s: &str) -> OctaveScriptBuilder

Adds the string to the Octave script.

At the end of the line a semicolon is appended.

Source

pub 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"
);
Source

pub 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"
);
Source

pub 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"
);
Source

pub 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"
);
Source

pub 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"
);
Source

pub fn octave_bin(&self, path: &str) -> OctaveScriptBuilder

Source

pub fn to_string(&self) -> String

Source

pub fn write(&self, filename: &str) -> Result<()>

Source

pub fn run(&self, filename: &str) -> Result<Output>

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.