QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Related Functions | List of all members
Array Class Reference

1-D array used in linear algebra. More...

#include <ql/math/array.hpp>

+ Collaboration diagram for Array:

Public Member Functions

Constructors, destructor, and assignment
 Array ()
 creates the array with size 0 More...
 
 Array (Size size)
 creates the array with the given dimension More...
 
 Array (Size size, Real value)
 creates the array and fills it with value More...
 
 Array (Size size, Real value, Real increment)
 creates the array and fills it according to \( a_{0} = value, a_{i}=a_{i-1}+increment \) More...
 
 Array (const Array &)
 
 Array (Array &&) noexcept
 
 Array (std::initializer_list< Real >)
 
template<class ForwardIterator >
 Array (ForwardIterator begin, ForwardIterator end)
 creates the array from an iterable sequence More...
 
 ~Array ()=default
 
Arrayoperator= (const Array &)
 
Arrayoperator= (Array &&) noexcept
 
bool operator== (const Array &) const
 
bool operator!= (const Array &) const
 
Vector algebra

v += x and similar operation involving a scalar value are shortcuts for \( \forall i : v_i = v_i + x \)

v *= w and similar operation involving two vectors are shortcuts for \( \forall i : v_i = v_i \times w_i \)

Precondition
all arrays involved in an algebraic expression must have the same size.
const Arrayoperator+= (const Array &)
 
const Arrayoperator+= (Real)
 
const Arrayoperator-= (const Array &)
 
const Arrayoperator-= (Real)
 
const Arrayoperator*= (const Array &)
 
const Arrayoperator*= (Real)
 
const Arrayoperator/= (const Array &)
 
const Arrayoperator/= (Real)
 
Element access
Real operator[] (Size) const
 read-only More...
 
Real at (Size) const
 
Real front () const
 
Real back () const
 
Realoperator[] (Size)
 read-write More...
 
Realat (Size)
 
Realfront ()
 
Realback ()
 
Iterator access
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rend () const
 
reverse_iterator rend ()
 

Related Functions

(Note that these are not member functions.)

Real DotProduct (const Array &, const Array &)
 
Real Norm2 (const Array &)
 
Array operator+ (const Array &v)
 
Array operator+ (Array &&v)
 
Array operator- (const Array &v)
 
Array operator- (Array &&v)
 
Array operator+ (const Array &, const Array &)
 
Array operator+ (const Array &, Array &&)
 
Array operator+ (Array &&, const Array &)
 
Array operator+ (Array &&, Array &&)
 
Array operator+ (const Array &, Real)
 
Array operator+ (Array &&, Real)
 
Array operator+ (Real, const Array &)
 
Array operator+ (Real, Array &&)
 
Array operator- (const Array &, const Array &)
 
Array operator- (const Array &, Array &&)
 
Array operator- (Array &&, const Array &)
 
Array operator- (Array &&, Array &&)
 
Array operator- (const Array &, Real)
 
Array operator- (Real, const Array &)
 
Array operator- (Array &&, Real)
 
Array operator- (Real, Array &&)
 
Array operator* (const Array &, const Array &)
 
Array operator* (const Array &, Array &&)
 
Array operator* (Array &&, const Array &)
 
Array operator* (Array &&, Array &&)
 
Array operator* (const Array &, Real)
 
Array operator* (Real, const Array &)
 
Array operator* (Array &&, Real)
 
Array operator* (Real, Array &&)
 
Array operator/ (const Array &, const Array &)
 
Array operator/ (const Array &, Array &&)
 
Array operator/ (Array &&, const Array &)
 
Array operator/ (Array &&, Array &&)
 
Array operator/ (const Array &, Real)
 
Array operator/ (Real, const Array &)
 
Array operator/ (Array &&, Real)
 
Array operator/ (Real, Array &&)
 
Array Abs (const Array &)
 
Array Abs (Array &&)
 
Array Sqrt (const Array &)
 
Array Sqrt (Array &&)
 
Array Log (const Array &)
 
Array Log (Array &&)
 
Array Exp (const Array &)
 
Array Exp (Array &&)
 
Array Pow (const Array &, Real)
 
Array Pow (Array &&, Real)
 
void swap (Array &, Array &) noexcept
 
std::ostream & operator<< (std::ostream &, const Array &)
 

Inspectors

typedef Size size_type
 
typedef Real value_type
 
typedef Realiterator
 
typedef const Realconst_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
Size size () const
 dimension of the array More...
 
bool empty () const
 whether the array is empty More...
 

Utilities

std::unique_ptr< Real[]> data_
 
Size n_
 
void resize (Size n)
 
void swap (Array &) noexcept
 

Detailed Description

1-D array used in linear algebra.

This class implements the concept of vector as used in linear algebra. As such, it is not meant to be used as a container - std::vector should be used instead.

Tests:
construction of arrays is checked in a number of cases
Examples
Gaussian1dModels.cpp, and GlobalOptimizer.cpp.

Definition at line 52 of file array.hpp.

Member Typedef Documentation

◆ size_type

typedef Size size_type

Definition at line 121 of file array.hpp.

◆ value_type

typedef Real value_type

Definition at line 122 of file array.hpp.

◆ iterator

typedef Real* iterator

Definition at line 123 of file array.hpp.

◆ const_iterator

typedef const Real* const_iterator

Definition at line 124 of file array.hpp.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> reverse_iterator

Definition at line 125 of file array.hpp.

◆ const_reverse_iterator

typedef std::reverse_iterator<const_iterator> const_reverse_iterator

Definition at line 126 of file array.hpp.

Constructor & Destructor Documentation

◆ Array() [1/8]

Array ( )

creates the array with size 0

Definition at line 57 of file array.hpp.

◆ Array() [2/8]

Array ( Size  size)
explicit

creates the array with the given dimension

Definition at line 284 of file array.hpp.

◆ Array() [3/8]

Array ( Size  size,
Real  value 
)

creates the array and fills it with value

Definition at line 287 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [4/8]

Array ( Size  size,
Real  value,
Real  increment 
)

creates the array and fills it according to \( a_{0} = value, a_{i}=a_{i-1}+increment \)

Definition at line 292 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [5/8]

Array ( const Array from)

Definition at line 298 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [6/8]

Array ( Array &&  from)
noexcept

Definition at line 304 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [7/8]

Array ( std::initializer_list< Real init)

Definition at line 346 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [8/8]

Array ( ForwardIterator  begin,
ForwardIterator  end 
)

creates the array from an iterable sequence

Definition at line 352 of file array.hpp.

+ Here is the call graph for this function:

◆ ~Array()

~Array ( )
default

Member Function Documentation

◆ operator=() [1/2]

Array & operator= ( const Array from)

Definition at line 359 of file array.hpp.

+ Here is the call graph for this function:

◆ operator=() [2/2]

Array & operator= ( Array &&  from)
noexcept

Definition at line 366 of file array.hpp.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const Array to) const

Definition at line 371 of file array.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator!=()

bool operator!= ( const Array to) const

Definition at line 375 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+=() [1/2]

const Array & operator+= ( const Array v)

Definition at line 379 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+=() [2/2]

const Array & operator+= ( Real  x)

Definition at line 388 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-=() [1/2]

const Array & operator-= ( const Array v)

Definition at line 393 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-=() [2/2]

const Array & operator-= ( Real  x)

Definition at line 401 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*=() [1/2]

const Array & operator*= ( const Array v)

Definition at line 406 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*=() [2/2]

const Array & operator*= ( Real  x)

Definition at line 414 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/=() [1/2]

const Array & operator/= ( const Array v)

Definition at line 419 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/=() [2/2]

const Array & operator/= ( Real  x)

Definition at line 427 of file array.hpp.

+ Here is the call graph for this function:

◆ operator[]() [1/2]

Real operator[] ( Size  i) const

read-only

Definition at line 435 of file array.hpp.

◆ at() [1/2]

Real at ( Size  i) const

Definition at line 444 of file array.hpp.

+ Here is the caller graph for this function:

◆ front() [1/2]

Real front ( ) const

Definition at line 451 of file array.hpp.

+ Here is the caller graph for this function:

◆ back() [1/2]

Real back ( ) const

Definition at line 458 of file array.hpp.

+ Here is the caller graph for this function:

◆ operator[]() [2/2]

Real & operator[] ( Size  i)

read-write

Definition at line 465 of file array.hpp.

◆ at() [2/2]

Real & at ( Size  i)

Definition at line 474 of file array.hpp.

◆ front() [2/2]

Real & front ( )

Definition at line 481 of file array.hpp.

◆ back() [2/2]

Real & back ( )

Definition at line 488 of file array.hpp.

◆ size()

Size size ( ) const

dimension of the array

Examples
GlobalOptimizer.cpp.

Definition at line 495 of file array.hpp.

+ Here is the caller graph for this function:

◆ empty()

bool empty ( ) const

whether the array is empty

Examples
GlobalOptimizer.cpp.

Definition at line 499 of file array.hpp.

+ Here is the caller graph for this function:

◆ begin() [1/2]

Array::const_iterator begin ( ) const

Definition at line 503 of file array.hpp.

+ Here is the caller graph for this function:

◆ begin() [2/2]

Array::iterator begin ( )

Definition at line 507 of file array.hpp.

◆ end() [1/2]

Array::const_iterator end ( ) const

Definition at line 511 of file array.hpp.

+ Here is the caller graph for this function:

◆ end() [2/2]

Array::iterator end ( )

Definition at line 515 of file array.hpp.

◆ rbegin() [1/2]

Definition at line 519 of file array.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rbegin() [2/2]

Definition at line 523 of file array.hpp.

+ Here is the call graph for this function:

◆ rend() [1/2]

Definition at line 527 of file array.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rend() [2/2]

Definition at line 531 of file array.hpp.

+ Here is the call graph for this function:

◆ resize()

void resize ( Size  n)

Definition at line 535 of file array.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void swap ( Array from)
noexcept

Definition at line 546 of file array.hpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ DotProduct()

Real DotProduct ( const Array ,
const Array  
)
related

Definition at line 553 of file array.hpp.

+ Here is the call graph for this function:

◆ Norm2()

Real Norm2 ( const Array )
related

Definition at line 560 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [1/10]

Array operator+ ( const Array v)
related

Definition at line 568 of file array.hpp.

◆ operator+() [2/10]

Array operator+ ( Array &&  v)
related

Definition at line 573 of file array.hpp.

◆ operator-() [1/10]

Array operator- ( const Array v)
related

Definition at line 577 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [2/10]

Array operator- ( Array &&  v)
related

Definition at line 583 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [3/10]

Array operator+ ( const Array ,
const Array  
)
related

Definition at line 591 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [4/10]

Array operator+ ( const Array ,
Array &&   
)
related

Definition at line 600 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [5/10]

Array operator+ ( Array &&  ,
const Array  
)
related

Definition at line 609 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [6/10]

Array operator+ ( Array &&  ,
Array &&   
)
related

Definition at line 618 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [7/10]

Array operator+ ( const Array ,
Real   
)
related

Definition at line 627 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [8/10]

Array operator+ ( Array &&  ,
Real   
)
related

Definition at line 633 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [9/10]

Array operator+ ( Real  ,
const Array  
)
related

Definition at line 639 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [10/10]

Array operator+ ( Real  ,
Array &&   
)
related

Definition at line 645 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [3/10]

Array operator- ( const Array ,
const Array  
)
related

Definition at line 651 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [4/10]

Array operator- ( const Array ,
Array &&   
)
related

Definition at line 660 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [5/10]

Array operator- ( Array &&  ,
const Array  
)
related

Definition at line 669 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [6/10]

Array operator- ( Array &&  ,
Array &&   
)
related

Definition at line 678 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [7/10]

Array operator- ( const Array ,
Real   
)
related

Definition at line 687 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [8/10]

Array operator- ( Real  ,
const Array  
)
related

Definition at line 699 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [9/10]

Array operator- ( Array &&  ,
Real   
)
related

Definition at line 693 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [10/10]

Array operator- ( Real  ,
Array &&   
)
related

Definition at line 705 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [1/8]

Array operator* ( const Array ,
const Array  
)
related

Definition at line 711 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [2/8]

Array operator* ( const Array ,
Array &&   
)
related

Definition at line 720 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [3/8]

Array operator* ( Array &&  ,
const Array  
)
related

Definition at line 729 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [4/8]

Array operator* ( Array &&  ,
Array &&   
)
related

Definition at line 738 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [5/8]

Array operator* ( const Array ,
Real   
)
related

Definition at line 747 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [6/8]

Array operator* ( Real  ,
const Array  
)
related

Definition at line 759 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [7/8]

Array operator* ( Array &&  ,
Real   
)
related

Definition at line 753 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [8/8]

Array operator* ( Real  ,
Array &&   
)
related

Definition at line 765 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [1/8]

Array operator/ ( const Array ,
const Array  
)
related

Definition at line 771 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [2/8]

Array operator/ ( const Array ,
Array &&   
)
related

Definition at line 780 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [3/8]

Array operator/ ( Array &&  ,
const Array  
)
related

Definition at line 789 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [4/8]

Array operator/ ( Array &&  ,
Array &&   
)
related

Definition at line 798 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [5/8]

Array operator/ ( const Array ,
Real   
)
related

Definition at line 807 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [6/8]

Array operator/ ( Real  ,
const Array  
)
related

Definition at line 819 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [7/8]

Array operator/ ( Array &&  ,
Real   
)
related

Definition at line 813 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [8/8]

Array operator/ ( Real  ,
Array &&   
)
related

Definition at line 825 of file array.hpp.

+ Here is the call graph for this function:

◆ Abs() [1/2]

Array Abs ( const Array )
related

Definition at line 833 of file array.hpp.

+ Here is the call graph for this function:

◆ Abs() [2/2]

Array Abs ( Array &&  )
related

Definition at line 840 of file array.hpp.

+ Here is the call graph for this function:

◆ Sqrt() [1/2]

Array Sqrt ( const Array )
related

Definition at line 847 of file array.hpp.

+ Here is the call graph for this function:

◆ Sqrt() [2/2]

Array Sqrt ( Array &&  )
related

Definition at line 854 of file array.hpp.

+ Here is the call graph for this function:

◆ Log() [1/2]

Array Log ( const Array )
related

Definition at line 861 of file array.hpp.

+ Here is the call graph for this function:

◆ Log() [2/2]

Array Log ( Array &&  )
related

Definition at line 868 of file array.hpp.

+ Here is the call graph for this function:

◆ Exp() [1/2]

Array Exp ( const Array )
related

Definition at line 875 of file array.hpp.

+ Here is the call graph for this function:

◆ Exp() [2/2]

Array Exp ( Array &&  )
related

Definition at line 882 of file array.hpp.

+ Here is the call graph for this function:

◆ Pow() [1/2]

Array Pow ( const Array ,
Real   
)
related

Definition at line 889 of file array.hpp.

+ Here is the call graph for this function:

◆ Pow() [2/2]

Array Pow ( Array &&  ,
Real   
)
related

Definition at line 896 of file array.hpp.

+ Here is the call graph for this function:

◆ swap()

void swap ( Array ,
Array  
)
related

Definition at line 903 of file array.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const Array  
)
related

Definition at line 907 of file array.hpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ data_

std::unique_ptr<Real[]> data_
private

Definition at line 145 of file array.hpp.

◆ n_

Size n_
private

Definition at line 146 of file array.hpp.