libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar >
template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
class libsemigroups::StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar >

Defined in matrix.hpp.

This is a class for views into a row of a matrix over a semiring. An instance of this class provides access to the elements in a row of a matrix and is cheap to create and copy. Addition, scalar multiplication, and other standard vector operations are defined for row views.

This class is the type of row views into a StaticMatrix; see the documentation for StaticMatrix for further details.

Template Parameters
PlusOpa stateless type with a call operator of signature scalar_type operator()(scalar_type, scalar_type) implementing the addition of the semiring.
ProdOpa stateless type with a call operator of signature scalar_type operator()(scalar_type, scalar_type) implementing the multiplication of the semiring.
ZeroOpa stateless type with a call operator of signature scalar_type operator()() returning the zero of the semiring (the additive identity element).
OneOpa stateless type with a call operator of signature scalar_type operator()() returning the one of the semiring (the multiplicative identity element).
Cthe number of columns of the underlying matrix.
Scalarthe type of the entries in the matrices (the type of elements in the underlying semiring).
Warning
If the underlying matrix is destroyed, then any row views for that matrix are invalidated.

Public Types

using const_iterator = typename RowViewCommon::const_iterator
 Alias for const iterators pointing at entries of a matrix.
 
using iterator = typename RowViewCommon::iterator
 Alias for const iterators pointing at entries of a matrix.
 
using matrix_type = typename RowViewCommon::matrix_type
 Alias for the type of the underlying matrix.
 
using Row = typename matrix_type::Row
 Alias for the type of a row in the underlying matrix.
 
using scalar_const_reference = typename RowViewCommon::scalar_const_reference
 Alias for const references to the template parameter Scalar.
 
using scalar_reference = typename RowViewCommon::scalar_reference
 Alias for references to the template parameter Scalar.
 
using scalar_type = Scalar
 Alias for the template parameter Scalar.
 

Public Member Functions

 StaticRowView ()=default
 Default constructor.
 
 StaticRowView (Row const &r)
 Construct a row view from a Row.
 
 StaticRowView (StaticRowView &&)=default
 Default move constructor.
 
 StaticRowView (StaticRowView const &)=default
 Default copy constructor.
 
iterator begin () noexcept
 Returns a iterator pointing at the first entry.
 
const_iterator cbegin () const noexcept
 Returns a const iterator pointing at the first entry.
 
iterator cend ()
 Returns a const iterator pointing one beyond the last entry of the row.
 
iterator end ()
 Returns a iterator pointing one beyond the last entry of the row.
 
template<typename U>
bool operator!= (U const &that) const
 Inequality operator.
 
scalar_reference operator() (size_t i)
 Returns a reference to the specified entry of the row.
 
scalar_const_reference operator() (size_t i) const
 Returns a const reference to the specified entry of the row.
 
Row operator* (scalar_type a) const
 Multiplies every entry of the row by a scalar.
 
void operator*= (scalar_type a)
 Multiplies every entry of the row by a scalar in-place.
 
Row operator+ (StaticRowView const &that)
 Sum row views.
 
void operator+= (scalar_type a)
 Adds a scalar to every entry of a row in-place.
 
void operator+= (StaticRowView const &that)
 Sums a row view with another row view in-place.
 
template<typename U>
bool operator< (U const &that) const
 Lexicographical comparison of rows.
 
template<typename U>
bool operator< (U const &that) const
 Lexicographical comparison of rows.
 
StaticRowViewoperator= (StaticRowView &&)=default
 Default move assignment operator.
 
StaticRowViewoperator= (StaticRowView const &)=default
 Default copy assignment operator.
 
template<typename U>
bool operator== (U const &that) const
 Equality operator.
 
scalar_reference operator[] (size_t i)
 Returns a reference to the specified entry of the row.
 
scalar_const_reference operator[] (size_t i) const
 Returns a const reference to the specified entry of the row.
 

Static Public Member Functions

static constexpr size_t size () const noexcept
 Returns the size of the row.
 

Constructor & Destructor Documentation

◆ StaticRowView() [1/4]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView ( )
default

Default constructor.

◆ StaticRowView() [2/4]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > const & )
default

Default copy constructor.

◆ StaticRowView() [3/4]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > && )
default

Default move constructor.

◆ StaticRowView() [4/4]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView ( Row const & r)
explicit

This function constructs a row view from a Row.

Parameters
rthe row.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant.

Member Function Documentation

◆ begin()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
iterator begin ( )
noexcept

This function returns a (random access) iterator pointing at the first entry in the row.

Returns
A value of type iterator.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant

◆ cbegin()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
const_iterator cbegin ( ) const
noexcept

This function returns a const (random access) iterator pointing at the first entry in the row.

Returns
A value of type const_iterator.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant

◆ cend()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
iterator cend ( )

This function returns a (random access) const iterator pointing at one beyond the last entry in the row.

Returns
A value of type iterator.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant

◆ end()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
iterator end ( )

This function returns a (random access) iterator pointing at one beyond the last entry in the row.

Returns
A value of type iterator.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant

◆ operator!=()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
template<typename U>
bool operator!= ( U const & that) const

Inequality operator.

Template Parameters
Ueither Row, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic)
Parameters
thatRow, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic) object for comparison.
Returns
Returns true if the first size entries of that do not equal the entries of this, and false otherwise.
Complexity
At worst \(O(n)\) where \(n\) is the size of the row view.

◆ operator()() [1/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
scalar_reference operator() ( size_t i)

This function returns a reference to the specified entry of the row.

Parameters
ithe index of the entry.
Returns
A value of type scalar_reference.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant
Warning
No checks on the validity of the parameter i is performed.

◆ operator()() [2/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
scalar_const_reference operator() ( size_t i) const

This function returns a const reference to the specified entry of the row.

Parameters
ithe index of the entry.
Returns
A value of type scalar_const_reference.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant
Warning
No checks on the validity of the parameter i is performed.

◆ operator*()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
Row operator* ( scalar_type a) const

This function multiplies every entry of the row by a scalar.

Parameters
athe scalar.
Returns
A value of type Row containing the original row multiplied by the scalar a.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is size.
Warning
This function does not detect overflows of scalar_type.

◆ operator*=()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
void operator*= ( scalar_type a)

This function multiplies every entry of the row by a scalar in-place.

Parameters
athe scalar to multiply by.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is size.
Warning
This function does not detect overflows of scalar_type.

◆ operator+()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
Row operator+ ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > const & that)

This function sums a row view with another row view and returns a newly allocated Row.

Parameters
thatthe row view to add.
Returns
A Row containing the sum.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is size.
Warning
The two row views must be of the same size, although this is not verified by the implementation.
This function does not detect overflows of scalar_type.

◆ operator+=() [1/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
void operator+= ( scalar_type a)

This function adds a scalar to every entry of the row in-place.

Parameters
athe scalar to add.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is size.
Warning
This function does not detect overflows of scalar_type.

◆ operator+=() [2/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
void operator+= ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > const & that)

This function redefines a RowView object to be the sum of itself and that.

Parameters
thatthe row view to add.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is size.
Warning
The two row views must be of the same size, although this is not verified by the implementation.
This function does not detect overflows of scalar_type.

◆ operator<() [1/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
template<typename U>
bool operator< ( U const & that) const

Lexicographical comparison of rows.

Template Parameters
Ueither Row, StaticRowView, DynamicRowView (compile-time arithmetic), //NOLINT() or DynamicRowView (run-time arithmetic). //NOLINT()
Parameters
thatRow, StaticRowView, DynamicRowView (compile-timearithmetic)", or \ref DynamicRowViewDynamicArith "DynamicRowView (run-time arithmetic)" object for comparison.
Returns
Returns true if *this is lex less than that that and false otherwise.
Complexity
At worst \(O(n)\) where \(n\) is the size of the row view.

◆ operator<() [2/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
template<typename U>
bool operator< ( U const & that) const

Lexicographical comparison of rows.

Template Parameters
Ueither Row, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic)
Parameters
thatRow, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic) object for comparison.
Returns
Returns true if this is lex greater than that that and false otherwise.
Complexity
At worst \(O(n)\) where \(n\) is the size of the row view.

◆ operator=() [1/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView & operator= ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > && )
default

Default move assignment operator.

◆ operator=() [2/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
StaticRowView & operator= ( StaticRowView< PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar > const & )
default

Default copy assignment operator.

◆ operator==()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
template<typename U>
bool operator== ( U const & that) const

Equality operator.

Template Parameters
Ueither Row, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic)
Parameters
thatRow, StaticRowView, DynamicRowView (compile-time arithmetic), or DynamicRowView (run-time arithmetic) object for comparison.
Returns
Returns true if the first size entries of that equal the entries of this, and false if not.
Complexity
At worst \(O(n)\) where \(n\) is the size of the row view.

◆ operator[]() [1/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
scalar_reference operator[] ( size_t i)

This function returns a reference to the specified entry of the row.

Parameters
ithe index of the entry.
Returns
A value of type scalar_reference.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant
Warning
No checks on the validity of the parameter i is performed.

◆ operator[]() [2/2]

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
scalar_const_reference operator[] ( size_t i) const

This function returns a const reference to the specified entry of the row.

Parameters
ithe index of the entry.
Returns
A value of type scalar_const_reference.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant
Warning
No checks on the validity of the parameter i is performed.

◆ size()

template<typename PlusOp, typename ProdOp, typename ZeroOp, typename OneOp, size_t C, typename Scalar>
static constexpr size_t size ( ) const
staticconstexprnoexcept

Returns the size of the underlying row which equals the template parameter C.

Returns
The size of the row.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant

The documentation for this class was generated from the following file: