Skip to content

FiniteDimVectorField should be implemented for f64and f32 #98

@ErikDeSmedt

Description

@ErikDeSmedt

The FiniteDimVectorField should be implemented for the f32 and f64 type.

A motivating example is the representation of an Initial Value Problem.

extern crate alga;

use alga::general::RealField;
use alga::linear::FiniteDimVectorSpace;

pub struct IVPProblem<'a, T, S>                                                                                                                                                                                                                
where                                                                                                                                                                                                                                          
    T : RealField,                                                                                                                                                                                                                             
    S : FiniteDimVectorSpace<Field = T>                                                                                                                                                                                                        
{                                                                                                                                                                                                                                              
    initial_state : S,                                                                                                                                                                                                                         
    tspan: (T,T),                                                                                                                                                                                                                              
    func : &'a dyn Fn(&T, &S) -> S,                                                                                                                                                                                                            
}                                                                                                                                                                                                                                              

If we would now want to implement the exponential equation given by dy/dt=dy you could try to implement it as

fn main() {
        let ivp_problem =  IVPProblem {                                                                                                                                                                                                        
            initial_state : 1.0,                                                                                                                                                                                                               
            tspan : (0.0, 1.0),                                                                                                                                                                                                                
            func : &(|_, &y| y)                                                                                                                                                                                                                                                                                                                                                                                                                                               
        };     

        /// More code here
}

This would not compile because our initial_state is an f64-type and the trait FiniteDimVectorSpace<Field = f64> is not implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions