EllAlgo 1.6.13
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Arr Class Reference

1D or 2D array backed by std::vector<double> for small optimization problems More...

#include <arr.hpp>

Public Types

using value_type = double
 

Public Member Functions

 Arr ()=default
 Default constructor (empty array)
 
 Arr (size_t n)
 Construct 1D array of size n, zero-initialized.
 
 Arr (size_t r, size_t c)
 Construct 2D array with r rows, c columns, zero-initialized.
 
 Arr (size_t r, size_t c, double val)
 Construct 2D array with r rows, c columns, fill value val.
 
 Arr (std::initializer_list< double > il)
 Construct from initializer list (1D)
 
 Arr (std::vector< double > v)
 Construct from vector (1D)
 
doubleoperator() (size_t i)
 1D element access (mutable)
 
const doubleoperator() (size_t i) const
 1D element access (const)
 
doubleoperator() (size_t i, size_t j)
 2D element access (mutable), row-major
 
const doubleoperator() (size_t i, size_t j) const
 2D element access (const), row-major
 
doubleoperator[] (size_t i)
 1D element access (mutable)
 
const doubleoperator[] (size_t i) const
 1D element access (const)
 
size_t size () const
 Total number of elements.
 
size_t rows () const
 Number of rows (1 for 1D arrays)
 
size_t cols () const
 Number of columns (0 for 1D arrays)
 
bool is_2d () const
 Whether this is a 2D array (cols > 0)
 
doubledata ()
 Raw pointer to underlying data (mutable)
 
const doubledata () const
 Raw pointer to underlying data (const)
 
auto begin ()
 Iterator to beginning (mutable)
 
auto begin () const
 Iterator to beginning (const)
 
auto end ()
 Iterator past the end (mutable)
 
auto end () const
 Iterator past the end (const)
 
Arroperator+= (double s)
 Add scalar to all elements.
 
Arroperator-= (double s)
 Subtract scalar from all elements.
 
Arroperator*= (double s)
 Multiply all elements by scalar.
 
Arroperator+= (const Arr &other)
 Element-wise addition with another Arr.
 
Arroperator-= (const Arr &other)
 Element-wise subtraction with another Arr.
 

Detailed Description

1D or 2D array backed by std::vector<double> for small optimization problems

Member Typedef Documentation

◆ value_type

Constructor & Destructor Documentation

◆ Arr() [1/6]

Arr::Arr ( )
default

Default constructor (empty array)

◆ Arr() [2/6]

Arr::Arr ( size_t  n)
inlineexplicit

Construct 1D array of size n, zero-initialized.

◆ Arr() [3/6]

Arr::Arr ( size_t  r,
size_t  c 
)
inline

Construct 2D array with r rows, c columns, zero-initialized.

◆ Arr() [4/6]

Arr::Arr ( size_t  r,
size_t  c,
double  val 
)
inline

Construct 2D array with r rows, c columns, fill value val.

◆ Arr() [5/6]

Arr::Arr ( std::initializer_list< double il)
inline

Construct from initializer list (1D)

◆ Arr() [6/6]

Arr::Arr ( std::vector< double v)
inlineexplicit

Construct from vector (1D)

Member Function Documentation

◆ begin() [1/2]

auto Arr::begin ( )
inline

Iterator to beginning (mutable)

◆ begin() [2/2]

auto Arr::begin ( ) const
inline

Iterator to beginning (const)

◆ cols()

size_t Arr::cols ( ) const
inline

Number of columns (0 for 1D arrays)

◆ data() [1/2]

double * Arr::data ( )
inline

Raw pointer to underlying data (mutable)

◆ data() [2/2]

const double * Arr::data ( ) const
inline

Raw pointer to underlying data (const)

◆ end() [1/2]

auto Arr::end ( )
inline

Iterator past the end (mutable)

◆ end() [2/2]

auto Arr::end ( ) const
inline

Iterator past the end (const)

◆ is_2d()

bool Arr::is_2d ( ) const
inline

Whether this is a 2D array (cols > 0)

◆ operator()() [1/4]

double & Arr::operator() ( size_t  i)
inline

1D element access (mutable)

◆ operator()() [2/4]

const double & Arr::operator() ( size_t  i) const
inline

1D element access (const)

◆ operator()() [3/4]

double & Arr::operator() ( size_t  i,
size_t  j 
)
inline

2D element access (mutable), row-major

◆ operator()() [4/4]

const double & Arr::operator() ( size_t  i,
size_t  j 
) const
inline

2D element access (const), row-major

◆ operator*=()

Arr & Arr::operator*= ( double  s)
inline

Multiply all elements by scalar.

◆ operator+=() [1/2]

Arr & Arr::operator+= ( const Arr other)
inline

Element-wise addition with another Arr.

◆ operator+=() [2/2]

Arr & Arr::operator+= ( double  s)
inline

Add scalar to all elements.

◆ operator-=() [1/2]

Arr & Arr::operator-= ( const Arr other)
inline

Element-wise subtraction with another Arr.

◆ operator-=() [2/2]

Arr & Arr::operator-= ( double  s)
inline

Subtract scalar from all elements.

◆ operator[]() [1/2]

double & Arr::operator[] ( size_t  i)
inline

1D element access (mutable)

◆ operator[]() [2/2]

const double & Arr::operator[] ( size_t  i) const
inline

1D element access (const)

◆ rows()

size_t Arr::rows ( ) const
inline

Number of rows (1 for 1D arrays)

◆ size()

size_t Arr::size ( ) const
inline

Total number of elements.


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