Skip to main content

Module complexity

Module complexity 

Source
Expand description

Expression complexity analysis.

This module provides analysis tools for estimating the computational complexity of TLExpr expressions. It can estimate:

  • Operation counts (additions, multiplications, etc.)
  • Computational cost (weighted by operation type)
  • Nesting depth
  • Memory footprint estimates

§Usage

use tensorlogic_compiler::optimize::{analyze_complexity, ExpressionComplexity};
use tensorlogic_ir::{TLExpr, Term};

let x = TLExpr::pred("x", vec![Term::var("i")]);
let expr = TLExpr::mul(TLExpr::add(x, TLExpr::Constant(1.0)), TLExpr::Constant(2.0));
let complexity = analyze_complexity(&expr);

println!("Total cost: {}", complexity.total_cost());
println!("Operations: {}", complexity.total_operations());

Structs§

CostWeights
Cost weights for different operation types.
ExpressionComplexity
Detailed complexity analysis of an expression.

Functions§

analyze_complexity
Analyze the complexity of an expression.
compare_complexity
Compare two expressions by their complexity.