namespace solver

// namespaces

namespace xf::solver::internalPSQRT

// structs

template <
    int RowsColsA,
    typename InputType,
    typename OutputType
    >
struct backSubstituteTraits

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct backSubstituteTraits <RowsColsA, hls::x_complex <ap_fixed <W1, I1, Q1, O1, N1>>, hls::x_complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct backSubstituteTraits <RowsColsA, std::complex <ap_fixed <W1, I1, Q1, O1, N1>>, std::complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct backSubstituteTraits <RowsColsA, ap_fixed <W1, I1, Q1, O1, N1>, ap_fixed <W2, I2, Q2, O2, N2>>

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyInverseTraits <RowsColsA, ap_fixed <W1, I1, Q1, O1, N1>, ap_fixed <W2, I2, Q2, O2, N2>>

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyInverseTraits <RowsColsA, hls::x_complex <ap_fixed <W1, I1, Q1, O1, N1>>, hls::x_complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    int RowsColsA,
    typename InputType,
    typename OutputType
    >
struct choleskyInverseTraits

template <
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyInverseTraits <RowsColsA, std::complex <ap_fixed <W1, I1, Q1, O1, N1>>, std::complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    bool LowerTriangularL,
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyTraits <LowerTriangularL, RowsColsA, hls::x_complex <ap_fixed <W1, I1, Q1, O1, N1>>, hls::x_complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    bool LowerTriangularL,
    int RowsColsA,
    typename InputBaseType,
    typename OutputBaseType
    >
struct choleskyTraits <LowerTriangularL, RowsColsA, hls::x_complex <InputBaseType>, hls::x_complex <OutputBaseType>>

template <
    bool LowerTriangularL,
    int RowsColsA,
    typename InputBaseType,
    typename OutputBaseType
    >
struct choleskyTraits <LowerTriangularL, RowsColsA, std::complex <InputBaseType>, std::complex <OutputBaseType>>

template <
    bool LowerTriangularL,
    int RowsColsA,
    typename InputType,
    typename OutputType
    >
struct choleskyTraits

template <
    bool LowerTriangularL,
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyTraits <LowerTriangularL, RowsColsA, ap_fixed <W1, I1, Q1, O1, N1>, ap_fixed <W2, I2, Q2, O2, N2>>

template <
    bool LowerTriangularL,
    int RowsColsA,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct choleskyTraits <LowerTriangularL, RowsColsA, std::complex <ap_fixed <W1, I1, Q1, O1, N1>>, std::complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <typename T>
struct is_cmplx <hls::x_complex <T>>

template <typename T>
struct is_cmplx <std::complex <T>>

template <typename T>
struct is_cmplx

template <
    class TransposeFormA,
    class TransposeFormB,
    int RowsA,
    int ColsA,
    int RowsB,
    int ColsB,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct matrixMultiplyTraits <TransposeFormA, TransposeFormB, RowsA, ColsA, RowsB, ColsB, std::complex <ap_fixed <W1, I1, Q1, O1, N1>>, std::complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    class TransposeFormA,
    class TransposeFormB,
    int RowsA,
    int ColsA,
    int RowsB,
    int ColsB,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct matrixMultiplyTraits <TransposeFormA, TransposeFormB, RowsA, ColsA, RowsB, ColsB, ap_fixed <W1, I1, Q1, O1, N1>, ap_fixed <W2, I2, Q2, O2, N2>>

template <
    class TransposeFormA,
    class TransposeFormB,
    int RowsA,
    int ColsA,
    int RowsB,
    int ColsB,
    typename InputType,
    typename OutputType
    >
struct matrixMultiplyTraits

template <
    class TransposeFormA,
    class TransposeFormB,
    int RowsA,
    int ColsA,
    int RowsB,
    int ColsB,
    int W1,
    int I1,
    ap_q_mode Q1,
    ap_o_mode O1,
    int N1,
    int W2,
    int I2,
    ap_q_mode Q2,
    ap_o_mode O2,
    int N2
    >
struct matrixMultiplyTraits <TransposeFormA, TransposeFormB, RowsA, ColsA, RowsB, ColsB, hls::x_complex <ap_fixed <W1, I1, Q1, O1, N1>>, hls::x_complex <ap_fixed <W2, I2, Q2, O2, N2>>>

template <
    int RowsColsA,
    typename InputType,
    typename OutputType
    >
struct qrInverseTraits

template <
    int RowsColsA,
    typename InputType,
    typename OutputBaseType
    >
struct qrInverseTraits <RowsColsA, InputType, std::complex <OutputBaseType>>

template <
    int RowsColsA,
    typename InputType,
    typename OutputBaseType
    >
struct qrInverseTraits <RowsColsA, InputType, hls::x_complex <OutputBaseType>>

struct qrfTraits

template <
    int ROWS,
    int COLS,
    typename InputType
    >
struct qrf_alt_config

template <
    int RowsA,
    int ColsA,
    typename InputType,
    typename OutputType
    >
struct svdTraits

backSubstitute

#include "back_substitute.hpp"
template <
    int RowsColsA,
    typename InputType,
    typename OutputType,
    typename TRAITS = backSubstituteTraits<RowsColsA, InputType, OutputType>
    >
void backSubstitute (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixBStrm,
    int& is_singular
    )

backSubstitute

Parameters:

RowsColsA Row and column dimensions
InputType Input data type
OutputType Output data type
TRIATS Traits class
matrixAStrm Stream of Input matrix
matrixBStrm Stream of Output matrix.
is_singular Indicates the diagonal of B contains zeros.

cholesky

#include "cholesky.hpp"
template <
    bool LowerTriangularL,
    int RowsColsA,
    class InputType,
    class OutputType,
    typename TRAITS = choleskyTraits<LowerTriangularL, RowsColsA, InputType, OutputType>
    >
int cholesky (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixLStrm
    )

cholesky

Parameters:

LowerTriangularL When false generates the result in the upper triangle
RowsColsA Defines the matrix dimensions
InputType Input data type
OutputType Output data type
TRAITS choleskyTraits class
matrixAStrm Stream of Hermitian/symmetric positive definite input matrix
matrixLStrm Stream of Lower or upper triangular output matrix

Returns:

An integer type. 0=Success. 1=Failure. The function attempted to find the square root of a negative number i.e. the input matrix A was not Hermitian/symmetric positive definite.

choleskyInverse

#include "cholesky_inverse.hpp"
template <
    int RowsColsA,
    typename InputType,
    typename OutputType,
    typename CholeskyInverseTraits = choleskyInverseTraits<RowsColsA, InputType, OutputType>
    >
void choleskyInverse (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixInverseAStrm,
    int& cholesky_success
    )

CHOLESKY_INVERSE.

Parameters:

RowsColsA Defines the matrix dimensions
InputType Input data type
OutputType Output data type
CholeskyInverseTraits Traits class
matrixAStrm Stream of Square Hermitian/symmetric positive definite input matrix
matrixInverseAStrm Stream of Inverse of input matrix
cholesky_success Indicates if matrix A was successfully inverted. 0 = Success. 1 = Failure.

matrixMultiply

matrixMultiply overload (1)

#include "matrix_multiply.hpp"
template <
    class TransposeFormA1,
    class TransposeFormA2,
    int RowsA,
    int ColsA,
    int RowsC,
    int ColsC,
    typename InputType,
    typename OutputType,
    typename TRAITS = matrixMultiplyTraits<TransposeFormA1, TransposeFormA2, RowsA, ColsA, RowsA, ColsA, InputType, OutputType>
    >
void matrixMultiply (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixCStrm
    )

matrixMultiply entry point function for calculating matrix power.

Parameters:

TransposeFormA1 Defines if the first matix is transposed before the multiplication. Valid values are: NoTranspose, Transpose, ConjugateTranspose
TransposeFormA2 Defines if the second matix is transposed before the multiplication.
RowsA Defines the number of rows in the A matrix
ColsA Defines the number of columns in the A matrix
RowsC Defines the number of rows in the C matrix
ColsC Defines the number of columns in the C matrix
InputType Input data type
OutputType Output data type
TRAITS Traits class
matrixAStrm Stream of input matrix
matrixCStrm Stream of A^2 product output matrix

matrixMultiply overload (2)

#include "matrix_multiply.hpp"
template <
    class TransposeFormA,
    class TransposeFormB,
    int RowsA,
    int ColsA,
    int RowsB,
    int ColsB,
    int RowsC,
    int ColsC,
    typename InputType,
    typename OutputType,
    typename TRAITS = matrixMultiplyTraits<TransposeFormA, TransposeFormB, RowsA, ColsA, RowsB, ColsB, InputType, OutputType>
    >
void matrixMultiply (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <InputType>& matrixBStrm,
    hls::stream <OutputType>& matrixCStrm
    )

matrixMultiply entry point function.

Parameters:

TransposeFormA Defines if the A matix is transposed before the multiplication. Valid values are: NoTranspose, Transpose, ConjugateTranspose
TransposeFormB Defines if the B matix is transposed before the multiplication.
RowsA Defines the number of rows in the A matrix
ColsA Defines the number of columns in the A matrix
RowsB Defines the number of rows in the B matrix
ColsB Defines the number of columns in the B matrix
RowsC Defines the number of rows in the C matrix
ColsC Defines the number of columns in the C matrix
InputType Input data type
OutputType Output data type
TRAITS Traits class
matrixAStrm Stream of First input matrix
matrixBStrm Stream of Second input matrix
matrixCStrm Stream of AB product output matrix

qrInverse

#include "qr_inverse.hpp"
template <
    int RowsColsA,
    typename InputType,
    typename OutputType,
    typename QRInverseTraits = qrInverseTraits<RowsColsA, InputType, OutputType>
    >
void qrInverse (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixInverseAStrm,
    int& A_singular
    )

qrInverse the entry point function.

Parameters:

RowsColsA Defines the matrix dimensions
InputType Input data type
OutputType Output data type
QRInverseTraits QRInverse Traits class
matrixAStrm Stream of Input matrix A
matrixInverseAStrm Stream of Inverse of input matrix
A_singular Failure, matrix A is singular

qrf

#include "qrf.hpp"
template <
    bool TransposedQ,
    int RowsA,
    int ColsA,
    typename InputType,
    typename OutputType,
    typename QRF_TRAITS = qrfTraits
    >
void qrf (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixQStrm,
    hls::stream <OutputType>& matrixRStrm
    )

QRF, to computes the full QR factorization (QR decomposition) of input matrix A, A=QR, producing orthogonal output matrix Q and upper-triangular matrix R.

Parameters:

TransposedQ Selects whether Q is output in transposed form
RowsA Number of rows in input matrix A
ColsA Number of columns in input matrix A
InputType Input data type
OutputType Output data type
QRF_TRAITS qrfTraits type with specified values
matrixAStrm Stream of Input matrix
matrixQStrm Stream of Orthogonal output matrix
matrixRStrm Stream of Upper triangular output matrix

svd

#include "svd.hpp"
template <
    int RowsA,
    int ColsA,
    typename InputType,
    typename OutputType,
    typename SVDTraits = svdTraits<RowsA, ColsA, InputType, OutputType>
    >
void svd (
    hls::stream <InputType>& matrixAStrm,
    hls::stream <OutputType>& matrixSStrm,
    hls::stream <OutputType>& matrixUStrm,
    hls::stream <OutputType>& matrixVStrm
    )

SVD the entry point function.

Parameters:

RowsA Row dimension
ColsA Column dimension
InputType Input data type
OutputType Output data type
matrixAStrm Stream of input matrix
matrixSStrm Stream of singular values output matrix
matrixUStrm Stream of left singular vectors output matrix
matrixVStrm Stream of right singular vectors output matrix