Into

Modules

Documentation

classPiiSubmatrix

#include <PiiMatrix.h>

A matrix that provides a mutable reference to a PiiMatrix.

Inherits PiiConceptualMatrix< PiiSubmatrix< T >, Pii::RandomAccessMatrix >

Description

Sub-matrices are temporary in nature; they only exist as return values from PiiMatrix::operator()(int,int,int,int). Sub-matrices cannot be copied. Unfortunately, there is no elegant way of making a movable but non-copyable type in C++ prior to C++0x. Therefore, this class uses a bit of hackery to implement move semantics with the old C++ standard.

 PiiMatrix<int> mat(5,5);
 // Constructing a copy of a PiiSubmatrix is possible prior to
 // C++0x. This is however strongly discouraged. The following
 // won't compile if C++0x is enabled.
 PiiSubMatrix<int> sub(mat(1,1,2,2)); // WRONG!
 PiiSubMatrix<int> sub2(sub); // WRONG!
 // As a result, sub will be left in an empty state.

 // The following is legal in both old C++ and C++0x
 PiiMatrix<int> sub(mat(1,1,2,2)); // immutable shallow copy
 // Modifies the central portion of mat
 mat(1,1,3,3) *= 5;

Public types

typedef PiiMatrixTraits< PiiSubmatrix< T >, Pii::RandomAccessMatrix >

Constructors and destructor

( )

Public member functions

Traits::iterator
( )
Traits::const_iterator
( )
Traits::column_iterator
(
  • int index
)
Traits::const_column_iterator
(
  • int index
)
Traits::column_iterator
(
  • int index
)
Traits::const_column_iterator
(
  • int index
)
int
( )
Traits::iterator
end
( )
Traits::const_iterator
end
( )

Returns a reference to the wrapped matrix.

T &
(
  • int r
  • int c
)
T
(
  • int r
  • int c
)
(
  • typename Traits::value_type value
)

Sets all elements to value and returns a reference to this.

Traits::const_row_iterator
(
  • int index
)
Traits::row_iterator
(
  • int index
)
Traits::row_iterator
(
  • int index
)
Traits::const_row_iterator
(
  • int index
)
int
( )

Function details

  • PiiSubmatrix

    ( )
    [inline]
  • Traits::iterator begin

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

  • Traits::const_iterator begin

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

  • Traits::column_iterator columnBegin

    (
    • int index
    )
    [inline]
  • Traits::const_column_iterator columnBegin

    (
    • int index
    )
    [inline]
  • Traits::column_iterator columnEnd

    (
    • int index
    )
    [inline]
  • Traits::const_column_iterator columnEnd

    (
    • int index
    )
    [inline]
  • int columns

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

  • Traits::iterator end

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

  • Traits::const_iterator end

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

  • operator PiiMatrix< T > &

    ()
    [inline]

    Returns a reference to the wrapped matrix.

    This function makes it possible to pass a sub-matrix to a function that takes a PiiMatrix as a parameter.

     template <class T> void modify(PiiMatrix<T>& mat);
    
     // ...
     PiiMatrix<float> mat(3,5);
     // You need to explicitly specify the template parameter for
     // overload resolution.
     modify<float>(mat(1,0,1,-1));
    
  • T & operator()

    (
    • int r
    • int c
    )
    [inline]
  • T operator()

    (
    • int r
    • int c
    )
    [inline]
  • PiiSubmatrix & operator=

    (
    • typename Traits::value_type value
    )
    [inline]

    Sets all elements to value and returns a reference to this.

  • Traits::const_row_iterator rowBegin

    (
    • int index
    )
    [inline]
  • Traits::row_iterator rowBegin

    (
    • int index
    )
    [inline]
  • Traits::row_iterator rowEnd

    (
    • int index
    )
    [inline]
  • Traits::const_row_iterator rowEnd

    (
    • int index
    )
    [inline]
  • int rows

    ()
    [inline]

    Reimplemented from PiiConceptualMatrix.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.