Template Class ArrayMultiply#

Class Documentation#

template<typename ShapeTypeA, typename StorageTypeA, typename ShapeTypeB, typename StorageTypeB, typename Alpha, typename Beta>
class ArrayMultiply#

Class to represent an array multiplication (vector-vector, matrix-vector, matrix-matrix)

Template Parameters
  • ShapeTypeAShape of the first array

  • StorageTypeAStorage type of the first array

  • ShapeTypeBShape of the second array

  • StorageTypeBStorage type of the second array

  • Alpha – Type of \( \alpha \) scaling factor

  • Beta – Type of \( \beta \) scaling factor

Public Types

using TypeA = array::ArrayContainer<ShapeTypeA, StorageTypeA>#
using TypeB = array::ArrayContainer<ShapeTypeB, StorageTypeB>#
using ScalarA = typename StorageTypeA::Scalar#
using ScalarB = typename StorageTypeB::Scalar#
using Scalar = decltype(std::declval<ScalarA>() * std::declval<ScalarB>())#
using ShapeType = ShapeTypeA#
using BackendA = typename typetraits::TypeInfo<TypeA>::Backend#
using BackendB = typename typetraits::TypeInfo<TypeB>::Backend#
using Backend = decltype(typetraits::commonBackend<BackendA, BackendB>())#

Public Functions

ArrayMultiply() = delete#

Default constructor (deleted)

ArrayMultiply(const ArrayMultiply&) = default#

Copy constructor.

ArrayMultiply(ArrayMultiply&&) noexcept = default#

Move constructor.

ArrayMultiply(bool transA, bool transB, TypeA &&a, Alpha alpha, TypeB &&b, Beta beta)#

Full set of parameters.

Parameters
  • transA

  • transB

  • a

  • alpha

  • b

  • beta

ArrayMultiply(TypeA &&a, TypeB &&b)#

Array multiplication with \( \alpha = 1 \) and \( \beta = 0 \).

Parameters
  • a

  • b

ArrayMultiply(bool transA, bool transB, TypeA &&a, TypeB &&b)#

Array multiplication with \( \alpha = 1 \) and \( \beta = 0 \) and transpose options.

Parameters
  • transA

  • transB

  • a

  • b

ArrayMultiply &operator=(const ArrayMultiply&) = default#

Copy assignment operator.

Returns

Reference to this

ArrayMultiply &operator=(ArrayMultiply&&) noexcept = default#

Move assignment operator.

Returns

Reference to this

MatmulClass matmulClass() const#

Determine the class of the array multiplication.

The class of the array multiplication is determined by the shapes of the arrays. There are three supported cases:

  • Vector-vector dot product (both arrays are 1-dimensional vectors)

  • Matrix-vector product (first array is a 2-dimensional matrix, second array is a 1-dimensional vector)

  • Matrix-matrix product (both arrays are 2-dimensional matrices)

Returns

Class of the array multiplication

ShapeType calculateShape() const#
ShapeType shape() const#

Determine the shape of the result.

Returns

Shape of the result

size_t size() const#
int64_t ndim() const#

Determine the number of dimensions of the result.

Returns

Number of dimensions of the result

auto eval() const#

Force evaluation of the array multiplication, returning an Array object.

Returns

Array object containing the result

ScalarA alpha() const#

Get the scaling factor \( \alpha \).

Returns

\( \alpha \)

ScalarB beta() const#

Get the scaling factor \( \beta \).

Returns

\( \beta \)

bool transA() const#

Determine \( \mathrm{OP}_A \).

Returns

True: \( \mathrm{OP}_A(\mathbf{A}) = \mathbf{A}^T \), false: \( \mathrm{OP}_A(\mathbf{A}) = \mathbf{A} \)

bool transB() const#

Determine \( \mathrm{OP}_B \).

Returns

True: \( \mathrm{OP}_B(\mathbf{B}) = \mathbf{B}^T \), false: \( \mathrm{OP}_B(\mathbf{B}) = \mathbf{B} \)

const TypeA &a() const#

Get the first array.

Returns

First array

const TypeB &b() const#

Get the second array.

Returns

Second array

TypeA &a()#

Get the first array.

Returns

First array

TypeB &b()#

Get the second array.

Returns

Second array

template<typename StorageType>
void applyTo(array::ArrayContainer<ShapeType, StorageType> &out) const#

Apply the array multiplication to an array container.

Apply this operation to the provided Array, assuming that the Array has the correct shape. If the Array does not have the correct shape, an error is thrown.

Template Parameters

StorageTypeStorage type of the array container

Parameters

out – Array container to store the result in

template<typename T, typename Char, typename Ctx>
void str(const fmt::formatter<T, Char> &format, char bracket, char separator, Ctx &ctx) const#