Go to the documentation of this file.
26 #ifndef TILEDARRAY_NONINTRUSIVE_API_TENSOR_H__INCLUDED
27 #define TILEDARRAY_NONINTRUSIVE_API_TENSOR_H__INCLUDED
41 template <
typename,
typename>
283 template <
typename Left,
typename Right>
284 inline auto subt(
const Left& left,
const Right& right) {
285 return left.subt(right);
298 typename Left,
typename Right,
typename Scalar,
299 typename std::enable_if<detail::is_numeric_v<Scalar>>::type* =
nullptr>
300 inline auto subt(
const Left& left,
const Right& right,
const Scalar factor) {
301 return left.subt(right, factor);
312 template <
typename Left,
typename Right,
typename Perm,
313 typename = std::enable_if_t<detail::is_permutation_v<Perm>>>
314 inline auto subt(
const Left& left,
const Right& right,
const Perm& perm) {
315 return left.subt(right, perm);
329 typename Left,
typename Right,
typename Scalar,
typename Perm,
330 typename std::enable_if<detail::is_numeric_v<Scalar> &&
331 detail::is_permutation_v<Perm>>::type* =
nullptr>
332 inline auto subt(
const Left& left,
const Right& right,
const Scalar factor,
334 return left.subt(right, factor, perm);
345 typename Arg,
typename Scalar,
346 typename std::enable_if<detail::is_numeric_v<Scalar>>::type* =
nullptr>
347 inline auto subt(
const Arg& arg,
const Scalar value) {
348 return arg.subt(value);
360 typename Arg,
typename Scalar,
typename Perm,
361 typename std::enable_if<detail::is_numeric_v<Scalar> &&
362 detail::is_permutation_v<Perm>>::type* =
nullptr>
363 inline auto subt(
const Arg& arg,
const Scalar value,
const Perm& perm) {
364 return arg.subt(value, perm);
374 template <
typename Result,
typename Arg>
375 inline Result&
subt_to(Result& result,
const Arg& arg) {
376 return result.subt_to(arg);
389 typename Result,
typename Arg,
typename Scalar,
390 typename std::enable_if<detail::is_numeric_v<Scalar>>::type* =
nullptr>
391 inline Result&
subt_to(Result& result,
const Arg& arg,
const Scalar factor) {
392 return result.subt_to(arg, factor);
403 typename Result,
typename Scalar,
404 typename std::enable_if<detail::is_numeric_v<Scalar>>::type* =
nullptr>
405 inline Result&
subt_to(Result& result,
const Scalar value) {
406 return result.subt_to(value);
409 template <
typename... T>
412 template <
typename... T>
424 template <
typename Left,
typename Right>
425 inline auto mult(
const Left& left,
const Right& right) {
426 return left.mult(right);
438 template <
typename Left,
typename Right,
typename Scalar,
439 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar>>* =
nullptr>
440 inline auto mult(
const Left& left,
const Right& right,
const Scalar factor) {
441 return left.mult(right, factor);
453 typename Left,
typename Right,
typename Perm,
454 typename = std::enable_if_t<detail::is_permutation_v<Perm> &&
455 detail::has_member_function_mult_anyreturn_v<
456 const Left,
const Right&,
const Perm&>>>
457 inline auto mult(
const Left& left,
const Right& right,
const Perm& perm) {
458 return left.mult(right, perm);
471 template <
typename Left,
typename Right,
typename Scalar,
typename Perm,
472 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar> &&
473 detail::is_permutation_v<Perm>>* =
nullptr>
474 inline auto mult(
const Left& left,
const Right& right,
const Scalar factor,
476 return left.mult(right, factor, perm);
486 template <
typename Result,
typename Arg>
487 inline Result&
mult_to(Result& result,
const Arg& arg) {
488 return result.mult_to(arg);
500 template <
typename Result,
typename Arg,
typename Scalar,
501 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar>>* =
nullptr>
502 inline Result&
mult_to(Result& result,
const Arg& arg,
const Scalar factor) {
503 return result.mult_to(arg, factor);
506 template <
typename... T>
509 template <
typename... T>
526 template <
typename Left,
typename Right,
typename Op>
527 inline decltype(
auto)
binary(const Left& left, const Right& right,
Op&& op) {
528 return left.binary(right, std::forward<Op>(op));
544 template <
typename Left,
typename Right,
typename Op,
typename Perm,
545 typename = std::enable_if_t<detail::is_permutation_v<Perm>>>
546 inline decltype(
auto)
binary(const Left& left, const Right& right,
Op&& op,
548 return left.binary(right, std::forward<Op>(op), perm);
562 template <
typename Left,
typename Right,
typename Op>
564 return left.inplace_binary(right, std::forward<Op>(op));
567 template <
typename... T>
570 template <
typename... T>
585 template <
typename Arg>
586 inline auto neg(
const Arg& arg) {
596 template <
typename Arg,
typename Perm,
597 typename = std::enable_if_t<detail::is_permutation_v<Perm>>>
598 inline auto neg(
const Arg& arg,
const Perm& perm) {
599 return arg.neg(perm);
607 template <
typename Result>
609 return result.neg_to();
612 template <
typename... T>
615 template <
typename... T>
625 template <
typename Arg>
626 inline auto conj(
const Arg& arg) {
637 template <
typename Arg,
typename Scalar,
638 typename std::enable_if<
639 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
640 inline auto conj(
const Arg& arg,
const Scalar factor) {
641 return arg.conj(factor);
650 template <
typename Arg,
typename Perm,
651 typename = std::enable_if_t<detail::is_permutation_v<Perm>>>
652 inline auto conj(
const Arg& arg,
const Perm& perm) {
653 return arg.conj(perm);
665 typename Arg,
typename Scalar,
typename Perm,
666 typename std::enable_if<TiledArray::detail::is_numeric_v<Scalar> &&
667 detail::is_permutation_v<Perm>>::type* =
nullptr>
668 inline auto conj(
const Arg& arg,
const Scalar factor,
const Perm& perm) {
669 return arg.conj(factor, perm);
677 template <
typename Result>
679 return result.conj_to();
689 template <
typename Result,
typename Scalar,
690 typename std::enable_if<
691 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
692 inline Result&
conj_to(Result& result,
const Scalar factor) {
693 return result.conj_to(factor);
696 template <
typename... T>
699 template <
typename... T>
714 template <
typename Arg,
typename Op>
715 inline decltype(
auto)
unary(const Arg& arg,
Op&& op) {
716 return arg.unary(std::forward<Op>(op));
729 template <
typename Arg,
typename Op,
typename Perm,
730 typename = std::enable_if_t<detail::is_permutation_v<Perm>>>
731 inline decltype(
auto)
unary(const Arg& arg,
Op&& op, const Perm& perm) {
732 return arg.unary(std::forward<Op>(op), perm);
744 template <
typename Result,
typename Op>
746 return arg.inplace_unary(std::forward<Op>(op));
749 template <
typename... T>
752 template <
typename... T>
769 template <
typename Left,
typename Right,
typename Scalar,
770 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar>>* =
nullptr>
771 inline auto gemm(
const Left& left,
const Right& right,
const Scalar factor,
773 return left.gemm(right, factor, gemm_config);
791 template <
typename Result,
typename Left,
typename Right,
typename Scalar,
792 std::enable_if_t<TiledArray::detail::is_numeric_v<Scalar>>* =
nullptr>
793 inline Result&
gemm(Result& result,
const Left& left,
const Right& right,
795 return result.gemm(left, right, factor, gemm_config);
830 template <
typename Result,
typename Left,
typename Right,
831 typename ElementMultiplyAddOp,
832 std::enable_if_t<std::is_invocable_r_v<
833 void, std::remove_reference_t<ElementMultiplyAddOp>,
834 typename Result::value_type&,
const typename Left::value_type&,
835 const typename Right::value_type&>>* =
nullptr>
836 inline Result&
gemm(Result& result,
const Left& left,
const Right& right,
838 ElementMultiplyAddOp&& element_multiplyadd_op) {
840 left, right, gemm_config,
841 std::forward<ElementMultiplyAddOp>(element_multiplyadd_op));
844 template <
typename... T>
864 template <
typename Arg>
865 inline auto sum(
const Arg& arg) {
874 template <
typename Arg>
876 return arg.product();
885 template <
typename Arg>
887 return arg.squared_norm();
895 template <
typename Arg>
896 inline auto norm(
const Arg& arg) {
906 template <
typename Arg,
typename ResultType>
907 inline void norm(
const Arg& arg, ResultType& result) {
908 result = arg.template norm<ResultType>();
916 template <
typename Arg>
917 inline auto max(
const Arg& arg) {
926 template <
typename Arg>
927 inline auto min(
const Arg& arg) {
936 template <
typename Arg>
938 return arg.abs_max();
946 template <
typename Arg>
948 return arg.abs_min();
958 template <
typename Left,
typename Right>
959 inline auto dot(
const Left& left,
const Right& right) {
960 return left.dot(right);
970 template <
typename Left,
typename Right>
972 return left.inner_product(right);
978 template <
typename T>
981 template <
typename T>
984 template <
typename T>
987 template <
typename T,
typename ResultType = T>
989 decltype(
norm(std::declval<T>(), std::declval<ResultType&>()));
991 template <
typename T>
994 template <
typename T>
997 template <
typename T>
1000 template <
typename T>
1003 template <
typename L,
typename R>
decltype(auto) subt(const Tile< Left > &left, const Tile< Right > &right)
Subtract tile arguments.
decltype(conj(std::declval< T >()...)) result_of_conj_t
decltype(abs_max(std::declval< T >())) result_of_abs_max_t
decltype(auto) unary(const Tile< Arg > &arg, Op &&op)
Unary element-wise transform producing a new tile.
Contraction to *GEMM helper.
decltype(norm(std::declval< T >(), std::declval< ResultType & >())) result_of_norm_t
auto inner_product(const DistArray< Tile, Policy > &a, const DistArray< Tile, Policy > &b)
Tile< Left > & inplace_binary(Tile< Left > &left, const Tile< Right > &right, Op &&op)
Binary element-wise in-place transform.
decltype(min(std::declval< T >())) result_of_min_t
Tile< Result > & mult_to(Tile< Result > &result, const Tile< Arg > &arg)
Multiply to the result tile.
decltype(auto) binary(const Tile< Left > &left, const Tile< Right > &right, Op &&op)
Binary element-wise transform producing a new tile.
decltype(auto) conj(const Tile< Arg > &arg)
Create a complex conjugated copy of a tile.
decltype(mult_to(std::declval< T >()...)) result_of_mult_to_t
decltype(abs_min(std::declval< T >())) result_of_abs_min_t
auto dot(const DistArray< Tile, Policy > &a, const DistArray< Tile, Policy > &b)
decltype(auto) norm(const Tile< Arg > &arg)
Vector 2-norm of a tile.
decltype(auto) min(const Tile< Arg > &arg)
Minimum element of a tile.
decltype(binary(std::declval< T >()...)) result_of_binary_t
decltype(neg_to(std::declval< T >()...)) result_of_neg_to_t
auto abs_min(const DistArray< Tile, Policy > &a)
auto abs_max(const DistArray< Tile, Policy > &a)
decltype(gemm(std::declval< T >()...)) result_of_gemm_t
decltype(auto) neg(const Tile< Arg > &arg)
Negate the tile argument.
decltype(subt(std::declval< T >()...)) result_of_subt_t
decltype(auto) mult(const Tile< Left > &left, const Tile< Right > &right)
Multiplication tile arguments.
auto squared_norm(const DistArray< Tile, Policy > &a)
decltype(inplace_unary(std::declval< T >()...)) result_of_inplace_unary_t
decltype(conj_to(std::declval< T >()...)) result_of_conj_to_t
Tile< Result > & neg_to(Tile< Result > &result)
In-place negate tile.
decltype(unary(std::declval< T >()...)) result_of_unary_t
decltype(max(std::declval< T >())) result_of_max_t
Tile< Result > & inplace_unary(Tile< Result > &arg, Op &&op)
Unary element-wise in-place transform.
decltype(dot(std::declval< L >(), std::declval< R >())) result_of_dot_t
constexpr bool empty()
Test for empty tensors in an empty list.
decltype(auto) product(const Tile< Arg > &arg)
Multiply the elements of a tile.
decltype(squared_norm(std::declval< T >())) result_of_squared_norm_t
decltype(neg(std::declval< T >()...)) result_of_neg_t
decltype(auto) max(const Tile< Arg > &arg)
Maximum element of a tile.
decltype(inplace_binary(std::declval< T >()...)) result_of_inplace_binary_t
decltype(auto) sum(const Tile< Arg > &arg)
Sum the elements of a tile.
Tile< Result > & subt_to(Tile< Result > &result, const Tile< Arg > &arg)
Subtract from the result tile.
decltype(mult(std::declval< T >()...)) result_of_mult_t
decltype(subt_to(std::declval< T >()...)) result_of_subt_to_t
decltype(product(std::declval< T >())) result_of_product_t
Tile< Result > & conj_to(Tile< Result > &result)
In-place complex conjugate a tile.
decltype(sum(std::declval< T >())) result_of_sum_t
decltype(auto) gemm(const Tile< Left > &left, const Tile< Right > &right, const Scalar factor, const math::GemmHelper &gemm_config)
Contract 2 tensors over head/tail modes and scale the product.