11 for (
int n = 0;
auto &x : A) x = n++;
12 std::cout <<
"A = " << A << std::endl;
13 std::cout <<
"A.shape() = " << A.shape() << std::endl;
24 std::cout <<
"B = 2*A + 3 = " << B << std::endl;
28 for (
int n = 0;
auto &x : A2) x = 0.1 * n++;
30 for (
int n = 0;
auto &x : B2) x = 0.1 * n++;
33 std::cout <<
"C_il = A_ijk * B_jkl = " << C2 << std::endl;
40 std::cout <<
"A_ij * B_jk = " << Cm << std::endl;
45 std::cout <<
"dot(A2, A2) [indexed] = " << d_indexed << std::endl;
46 std::cout <<
"dot(A2, A2) [default] = " << d_default << std::endl;
52 std::cout <<
"reduce(A, NORM_2) = " <<
nda::tensor::reduce(A, binary_op::NORM_2) << std::endl;
56 for (
int n = 0;
auto &x : S) x =
static_cast<double>(n++ + 1);
58 std::cout <<
"2 * S = " << S << std::endl;
60 std::cout <<
"sqrt(2 * S) = " << S << std::endl;
63 using cplx = std::complex<double>;
65 for (
int n = 0;
auto &x : Z) {
70 std::cout <<
"conj(Z) = " << Z << std::endl;
74 for (
int n = 0;
auto &x : E1) x =
static_cast<double>(n++);
78 std::cout <<
"E2 <- E1 + E2 = " << E2 << std::endl;
85 std::cout <<
"F2 <- F1 * F2 = " << F2 << std::endl;
static basic_array zeros(std::array< Int, Rank > const &shape)
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
void add(get_value_t< A > alpha, A const &a, std::string_view idx_a, get_value_t< A > beta, B &&b, std::string_view idx_b)
Tensor addition with cuTENSOR/TBLIS/nda dispatch.
void contract(get_value_t< A > alpha, A const &a, std::string_view idx_a, B const &b, std::string_view idx_b, get_value_t< A > beta, C &&c, std::string_view idx_c)
Tensor contraction with cuTENSOR/TBLIS dispatch.
void scale(get_value_t< A > alpha, A &&a, unary_op op=unary_op::IDENTITY)
In-place tensor scaling with cuTENSOR/TBLIS/nda dispatch and optional element-wise unary operation.
get_value_t< A > dot(A const &a, std::string_view idx_a, B const &b, std::string_view idx_b)
Full tensor dot product with cuTENSOR/TBLIS/nda dispatch.
get_value_t< A > reduce(A const &a, binary_op op_reduce=binary_op::SUM)
Full tensor reduction with cuTENSOR/TBLIS/nda dispatch.
void elementwise(get_value_t< A > alpha, A const &a, std::string_view idx_a, get_value_t< A > beta, B &&b, std::string_view idx_b, binary_op op=binary_op::SUM)
In-place elementwise binary tensor operation with cuTENSOR/nda dispatch.
unary_op
Unary element-wise operations for tensor operations.
binary_op
Binary operations for tensor operations.
std::string_view default_index()
Generate a default index string ("abc...") of a given length.
Includes all relevant headers for the core nda library.