comet_fn!() { /* proc-macro */ }Expand description
COMET uses Einstein mathematical notation and The comet_fn! macro provides users with an interface to express tensor algebra semantics using a Rust-like eDSL.
§Syntax
function_name- is the (user defined) name of the COMET function and can be called directly from the rust program asfunction_name().eDSL code- is the eDSL code to be compiled by the COMET compiler.CometOptions- are optional optimizations to pass to the COMET compiler.
comet_rs::comet_fn! {function_name, {
eDSL code
}[,]
[CometOptions::[options],]
}§Example
comet_rs::comet_fn! { print_dense, {
let i = Index::with_value(4);
let j = Index::with_value(4);
let A = Tensor::<f64>::dense([i, j]).fill(2.3);
A.print();
}}
comet_rs::comet_fn! { sum_coo, {
let i = Index::new();
let j = Index::new();
let A = Tensor::<f64>::coo([i, j]).fill_from_file("../../../integration_test/data/test.mtx");
let a = A.sum();
a.print();
}}
comet_rs::comet_fn! { ccsd_t1_4_ttgt_bestperm, {
let i, c = Index::with_value(2);
let m, a = Index::with_value(4);
let v = Tensor::<f64>::dense([c, i, m, a]).fill(2.3);
let t2 = Tensor::<f64>::dense([m, c]).fill(3.4);
let i0 = Tensor::<f64>::dense([i, a]).fill(0.0);
i0 = v * t2;
i0.print();
},
CometOption::[BestPermTtgt, TcToTtgt]
}
fn main() {
print_dense();
sum_coo();
ccsd_t1_4_ttgt_bestperm();
}