FLAMES 0.1.0
Matrix-Empowered HLS Library
Loading...
Searching...
No Matches
core.hpp File Reference

Core Utilities for FLAMES. More...

#include <ap_fixed.h>
#include <ap_int.h>
#include <cassert>
#include <complex>
#include <cstddef>
#include <fstream>
#include <hls_vector.h>
#include <initializer_list>
#include <iostream>
#include <type_traits>
#include <vector>
Include dependency graph for core.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  flames::Mat< T, n_rows, n_cols, type >
 Matrix. More...
 
class  flames::MatView< T, n_rows, n_cols, type >
 Read only view version of a matrix. More...
 
class  flames::MatRef< T, n_rows, n_cols, type >
 
class  flames::MatViewOpp< T, n_rows, n_cols, type >
 Read only view version of the opposite of a matrix. More...
 
class  flames::MatViewT< T, n_rows, n_cols, type >
 Read only view version of a transposed matrix. More...
 
class  flames::MatViewDiagMat< T, N, N_, type, type_parent >
 Read only view version of a diagonal matrix. More...
 
class  flames::MatViewDiagVec< T, N, n_cols, type, type_parent >
 Read only view version of a diagonal matrix as vector. More...
 
class  flames::MatViewDiagRowVec< T, n_rows, N, type, type_parent >
 Read only view version of a diagonal matrix as row vector. More...
 
class  flames::MatViewOffDiag< T, N, N_, type, type_parent >
 Read only view version of a off diagonal. More...
 
class  flames::MatViewCol< T, n_rows, n_cols, type, type_parent >
 Read only view version of a certain column as colunm vector. More...
 
class  flames::MatViewRow< T, n_rows, n_cols, type, type_parent >
 Read only view version of a certain row as row vector. More...
 
class  flames::MatRefCol< T, n_rows, n_cols, type, type_parent >
 
class  flames::MatRefRow< T, n_rows, n_cols, type, type_parent >
 
class  flames::MatViewCols< first_col, last_col, T, n_rows, n_cols, type, type_parent >
 Read only view version of successive columns. More...
 
class  flames::MatViewRows< first_row, last_row, T, n_rows, n_cols, type, type_parent >
 Read only view version of successive rows. More...
 

Namespaces

namespace  flames
 Namespace for the FLAMES library.
 

Macros

#define PRAGMA_SUB(x)
 
#define FLAMES_PRAGMA(x)
 
#define FLAMES_MAT_PLUS_UNROLL_FACTOR   32
 
#define FLAMES_MAT_MINUS_UNROLL_FACTOR   32
 
#define FLAMES_MAT_SET_VALUE_UNROLL_FACTOR   32
 
#define FLAMES_MAT_POWER_UNROLL_FACTOR   32
 
#define FLAMES_MAT_COPY_UNROLL_FACTOR   32
 
#define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR   32
 
#define FLAMES_MAT_TIMES_UNROLL_FACTOR   32
 
#define FLAMES_MAT_EMUL_UNROLL_FACTOR   32
 
#define FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR   32
 
#define FLAMES_MAT_ABS_UNROLL_FACTOR   32
 
#define FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR   32
 
#define FLAMES_MAT_INV_UNROLL_FACTOR   32
 
#define FLAMES_MAT_PARTITION_FACTOR   8
 
#define FLAMES_SORT_PARTITION_FACTOR   32
 

Typedefs

using flames::MATTYPE_NORMAL = std::integral_constant<int, MatType::NORMAL>
 Normal matrix as a class type.
 
using flames::MATTYPE_DIAGONAL = std::integral_constant<int, MatType::DIAGONAL>
 Diagonal matrix as a class type.
 
using flames::MATTYPE_SCALAR = std::integral_constant<int, MatType::SCALAR>
 Scalar matrix matrix as a class type.
 
using flames::MATTYPE_UPPER = std::integral_constant<int, MatType::UPPER>
 Upper triangular matrix as a class type.
 
using flames::MATTYPE_LOWER = std::integral_constant<int, MatType::LOWER>
 Lower triangular matrix as a class type.
 
using flames::MATTYPE_SUPPER = std::integral_constant<int, MatType::SUPPER>
 Strict upper triangular matrix as a class type.
 
using flames::MATTYPE_SLOWER = std::integral_constant<int, MatType::SLOWER>
 Strict lower triangular matrix as a class type.
 
using flames::MATTYPE_SYM = std::integral_constant<int, MatType::SYM>
 Symmetrical matrix as a class type.
 
using flames::MATTYPE_ASYM = std::integral_constant<int, MatType::ASYM>
 Antisymmetrical matrix as a class type.
 
template<int type>
using flames::MType = std::integral_constant<int, type>
 Get the class form of MatType.
 
template<typename T , size_t N>
using flames::Vec = Mat<T, N, 1>
 Column vector.
 
template<typename T , size_t N>
using flames::RowVec = Mat<T, 1, N>
 Row vector.
 

Enumerations

enum  flames::MatType {
  flames::NORMAL , flames::DIAGONAL , flames::SCALAR , flames::UPPER ,
  flames::LOWER , flames::SUPPER , flames::SLOWER , flames::SYM ,
  flames::ASYM
}
 Matrix type for storage. More...
 
enum class  flames::InitAfterwards { flames::NONE , flames::OPP , flames::TR }
 Afterwards action with initialization. More...
 
enum class  flames::Init { flames::NONE , flames::ZEROS , flames::ONES }
 

Functions

template<typename T >
constexpr MatType flames::matType ()
 Get the MatType value from the class form.
 
constexpr MatType flames::sumType (MatType type1, MatType type2) noexcept
 Summation type of two matrices.
 
constexpr MatType flames::mulType (MatType type1, MatType type2, size_t n_rows, size_t comm, size_t n_cols) noexcept
 Multiplication type of two matrices.
 
constexpr MatType flames::tType (MatType type) noexcept
 Transpose type of a matrix.
 
constexpr size_t flames::upperRow (size_t index, size_t N)
 Calculate the row index of a upper triangular matrix.
 
constexpr size_t flames::lowerRow (size_t index, size_t N)
 Calculate the row index of a lower triangular matrix.
 
constexpr size_t flames::supperRow (size_t index, size_t N)
 Calculate the row index of a strict upper triangular matrix.
 
constexpr size_t flames::slowerRow (size_t index, size_t N)
 Calculate the row index of a strict lower triangular matrix.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type1, MatType type2>
static Mat< T1, n_rows, n_cols, sumType(type1, type2)> flames::operator+ (const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
 Add two matrices and make a copy.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type1, MatType type2>
static Mat< T1, n_rows, n_cols, type1 > & flames::operator+= (Mat< T1, n_rows, n_cols, type1 > &mat_L, const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
 Matrix self plus a matrix.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type1, MatType type2>
static Mat< T1, n_rows, n_cols, sumType(type1, type2)> flames::operator- (const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
 Minus two matrices and make a copy.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type1, MatType type2>
static M1< T1, n_rows, n_cols, type1 > & flames::operator-= (M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
 Matrix self minus a matrix.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type1, MatType type2, std::enable_if_t<(std::is_same< T1, bool >::value), bool > = true>
static Mat< T1, n_rows, n_cols, mulType(type1, type2, n_rows, n_cols, n_cols)> flames::operator*= (Mat< T1, n_rows, n_cols, type1 > &mat, const M< T2, n_cols, n_cols, type2, _unused... > &mat_R)
 Matrix self times a matrix.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T , typename ScalarT , size_t n_rows, size_t n_cols, MatType type, std::enable_if_t< std::is_arithmetic< std::remove_reference_t< ScalarT > >::value, bool > = true>
static Mat< T, n_rows, n_cols, type > & flames::operator*= (const M< T, n_rows, n_cols, type, _unused... > &mat, ScalarT s)
 Matrix self times a scalar.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T , typename ScalarT , size_t n_rows, size_t n_cols, MatType type, std::enable_if_t< std::is_arithmetic< std::remove_reference_t< ScalarT > >::value, bool > = true>
static Mat< T, n_rows, n_cols, type > flames::operator* (const M< T, n_rows, n_cols, type, _unused... > &mat_L, ScalarT s)
 Matrix times a scalar.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T , size_t n_rows, size_t n_cols, MatType type, int AP_W, int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O, int AP_N>
static Mat< T, n_rows, n_cols, type > flames::operator* (const M< T, n_rows, n_cols, type, _unused... > &mat_L, ap_fixed< AP_W, AP_I, AP_Q, AP_O, AP_N > s)
 Matrix times an ap_fixed scalar.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T , typename ScalarT , size_t n_rows, size_t n_cols, MatType type, std::enable_if_t< std::is_arithmetic< std::remove_reference_t< ScalarT > >::value, bool > = true>
static Mat< T, n_rows, n_cols, type > flames::operator* (ScalarT s, const M< T, n_rows, n_cols, type, _unused... > &mat_R)
 Matrix times a scalar.
 
template<template< class, size_t, size_t, MatType, class... > typename M, typename... _unused, typename T , size_t n_rows, size_t n_cols, MatType type, int AP_W, int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O, int AP_N>
static Mat< T, n_rows, n_cols, type > flames::operator* (ap_fixed< AP_W, AP_I, AP_Q, AP_O, AP_N > s, const M< T, n_rows, n_cols, type, _unused... > &mat_R)
 Matrix times an ap_fixed scalar.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t comm, size_t n_cols, MatType type1, MatType type2, std::enable_if_t<(std::is_same< T1, bool >::value), bool > = true>
static Mat< T2, n_rows, n_cols, mulType(type1, type2, n_rows, comm, n_cols)> flames::operator* (const M1< T1, n_rows, comm, type1, _unused1... > &mat_L, const M2< T2, comm, n_cols, type2, _unused2... > &mat_R)
 Matrix multiplication.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t comm, size_t n_cols, MatType type1, MatType type2, std::enable_if_t<!(std::is_same< T1, bool >::value), bool > = true>
static Mat< T1, n_rows, n_cols, mulType(type1, type2, n_rows, comm, n_cols)> flames::operator* (const M1< T1, n_rows, comm, type1, _unused1... > &mat_L, const M2< T2, comm, n_cols, type2, _unused2... > &mat_R)
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< T1, n_rows, n_cols, type > flames::operator% (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise product of two matrices.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator== (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise equal comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator!= (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise unequal comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator> (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise greater comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator< (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise less comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator>= (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise greater or equal comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< bool, n_rows, n_cols, type > flames::operator<= (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise less or equal comparison.
 
template<template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t n_rows, size_t n_cols, MatType type>
Mat< T1, n_rows, n_cols, type > flames::mod (const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
 Element-wise modulus.
 
template<typename Tp = double, template< class, size_t, size_t, MatType, class... > typename M1, typename... _unused1, template< class, size_t, size_t, MatType, class... > typename M2, typename... _unused2, typename T1 , typename T2 , size_t L_rows, size_t L_cols, size_t R_rows, size_t R_cols, MatType type, std::enable_if_t< L_rows *L_cols==R_rows *R_cols, bool > = true>
Tp flames::innerProd (const M1< T1, L_rows, L_cols, type, _unused1... > &mat_L, const M2< T2, R_rows, R_cols, type, _unused2... > &mat_R)
 
template<typename T , size_t n_rows, size_t n_cols, MatType type>
static std::ostream & flames::operator<< (std::ostream &os, const Mat< T, n_rows, n_cols, type > &mat)
 Print matrix in a out stream.
 

Detailed Description

Core Utilities for FLAMES.

Author
Wuqiong Zhao (me@wq.nosp@m.zhao.nosp@m..org), et al.
Version
0.1.0
Date
2024-11-04

Macro Definition Documentation

◆ FLAMES_MAT_ABS_UNROLL_FACTOR

#define FLAMES_MAT_ABS_UNROLL_FACTOR   32

◆ FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR

#define FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR   32

◆ FLAMES_MAT_COPY_UNROLL_FACTOR

#define FLAMES_MAT_COPY_UNROLL_FACTOR   32

◆ FLAMES_MAT_EMUL_UNROLL_FACTOR

#define FLAMES_MAT_EMUL_UNROLL_FACTOR   32

◆ FLAMES_MAT_INV_UNROLL_FACTOR

#define FLAMES_MAT_INV_UNROLL_FACTOR   32

◆ FLAMES_MAT_MINUS_UNROLL_FACTOR

#define FLAMES_MAT_MINUS_UNROLL_FACTOR   32

◆ FLAMES_MAT_PARTITION_FACTOR

#define FLAMES_MAT_PARTITION_FACTOR   8

◆ FLAMES_MAT_PLUS_UNROLL_FACTOR

#define FLAMES_MAT_PLUS_UNROLL_FACTOR   32

◆ FLAMES_MAT_POWER_UNROLL_FACTOR

#define FLAMES_MAT_POWER_UNROLL_FACTOR   32

◆ FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR

#define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR   32

◆ FLAMES_MAT_SET_VALUE_UNROLL_FACTOR

#define FLAMES_MAT_SET_VALUE_UNROLL_FACTOR   32

◆ FLAMES_MAT_TIMES_UNROLL_FACTOR

#define FLAMES_MAT_TIMES_UNROLL_FACTOR   32

◆ FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR

#define FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR   32

◆ FLAMES_PRAGMA

#define FLAMES_PRAGMA ( x)
Value:
PRAGMA_SUB(HLS x)
#define PRAGMA_SUB(x)
Definition core.hpp:46

◆ FLAMES_SORT_PARTITION_FACTOR

#define FLAMES_SORT_PARTITION_FACTOR   32

◆ PRAGMA_SUB

#define PRAGMA_SUB ( x)
Value:
_Pragma(#x)