ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Matrix.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File Matrix.h ------------------------------*/
3/*--------------------------------------------------------------------------*/
49/*--------------------------------------------------------------------------*/
50/*----------------------------- DEFINITIONS --------------------------------*/
51/*--------------------------------------------------------------------------*/
52
53#ifndef __ADS_Matrix
54 #define __ADS_Matrix
55/* self-identification: #endif constant */
56
57/*--------------------------------------------------------------------------*/
58/*------------------------------ INCLUDES ----------------------------------*/
59/*--------------------------------------------------------------------------*/
60
61#include "ADS/Contract.h"
62
63#include <cstddef>
64#include <vector>
65
66/*--------------------------------------------------------------------------*/
67/*--------------------------- NAMESPACE ------------------------------------*/
68/*--------------------------------------------------------------------------*/
69
70namespace ADS
71{
72
73template< class T >
74using Matrix = std::vector< std::vector< T > >;
75
95template< class T >
97 long * mults = nullptr );
98
115template< class T >
117
120template< class T >
122
124template< class T >
125Matrix< T > scale( Matrix< T > A , const T & s );
126
127namespace detail
128{
129
131template< class T >
132bool hasShape( const Matrix< T > & A , std::size_t r , std::size_t c );
133
136template< class T >
137Matrix< T > block( const Matrix< T > & A , std::size_t r , std::size_t c ,
138 std::size_t h );
139
141template< class T >
142Matrix< T > plus( const Matrix< T > & A , const Matrix< T > & B , T s = 1 );
143
145template< class T >
146Matrix< T > strassenRec( const Matrix< T > & A , const Matrix< T > & B ,
147 std::size_t cutoff , long * mults );
148
149} // end( namespace detail )
150
177template< class T >
179 std::size_t cutoff = 1 , long * mults = nullptr );
180
181/*--------------------------------------------------------------------------*/
182
183} // end( namespace ADS )
184
185/*--------------------------------------------------------------------------*/
186/*-------------------------- IMPLEMENTATION --------------------------------*/
187/*--------------------------------------------------------------------------*/
188
189#include "ADS/numeric/impl/Matrix.tpp"
190
191/*--------------------------------------------------------------------------*/
192
193#endif /* Matrix.h included */
194
195/*--------------------------------------------------------------------------*/
196/*--------------------------- End File Matrix.h ----------------------------*/
197/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ListGraph transpose(const G &g)
the transposed graph, with the edges reversed
DenseMatrix< T > multiply(const DenseMatrix< T > &A, const DenseMatrix< T > &B)
the product , a new matrix, by gemm() with and
Matrix< T > multiplyNaive(const Matrix< T > &A, const Matrix< T > &B, long *mults=nullptr)
the product of two matrices by the definition, (the moltiplicaMatrici() of the book); the products...
Matrix< T > strassen(const Matrix< T > &A, const Matrix< T > &B, std::size_t cutoff=1, long *mults=nullptr)
the product by the algorithm of Strassen, , the blocks of at most rows by the naive method; the pro...
Matrix< T > scale(Matrix< T > A, const T &s)
the product of the matrix by a scalar
Definition ADT.h:96
std::vector< std::vector< T > > Matrix
by rows
Definition Matrix.h:74