Fixed basic problems
This commit is contained in:
parent
ce95eb2516
commit
06274cd5a5
3 changed files with 8 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ use crate::formula::node::Node;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
|
|
||||||
pub struct Formula {
|
pub struct Formula {
|
||||||
root: node::Node<F>,
|
root: node::Node,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Formula {
|
impl Formula {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
pub trait Function {
|
|
||||||
fn map(x: f64) -> f64;
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::formula::node::graph_constructor::GraphBuilder;
|
use crate::formula::node::graph_constructor::GraphBuilder;
|
||||||
|
|
||||||
mod function;
|
|
||||||
mod graph_constructor;
|
mod graph_constructor;
|
||||||
|
|
||||||
pub struct Node {
|
pub struct Node {
|
||||||
|
|
@ -20,8 +19,13 @@ impl Node {
|
||||||
}
|
}
|
||||||
pub fn get_value(&self) -> f64 {
|
pub fn get_value(&self) -> f64 {
|
||||||
if self.children.len() == 0 {
|
if self.children.len() == 0 {
|
||||||
0f64
|
return (self.function)(vec![0f64]);
|
||||||
}
|
}
|
||||||
for node in self.children {}
|
let mut inputs: Vec<f64> = vec![];
|
||||||
|
for node in &self.children {
|
||||||
|
inputs.push(node.get_value());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (self.function)(inputs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue