1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::operations::{DirectProduct, DotProduct};
use crate::{ConstantValue, Expression, TensorExpression};
use std::collections::HashMap;

impl TensorExpression {
    pub fn assign(self, variables: &HashMap<&str, ConstantValue>) -> Expression {
        match self {
            TensorExpression::KroneckerDeltas(_) => self.into(),
            TensorExpression::DotProduct {
                terms,
                rank_combinations,
            } => terms
                .into_iter()
                .map(|t| t.assign(variables))
                .dot_product(&rank_combinations),
            TensorExpression::DirectProduct(terms) => terms
                .into_iter()
                .map(|t| t.assign(variables))
                .direct_product(),
        }
    }
}