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

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

#include <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<typename T , typename = std::enable_if_t<std::is_convertible_v<T, Real>>>
 Array (std::initializer_list< T > init)
 
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 123 of file array.hpp.

◆ value_type

typedef Real value_type

Definition at line 124 of file array.hpp.

◆ iterator

typedef Real* iterator

Definition at line 125 of file array.hpp.

◆ const_iterator

typedef const Real* const_iterator

Definition at line 126 of file array.hpp.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> reverse_iterator

Definition at line 127 of file array.hpp.

◆ const_reverse_iterator

typedef std::reverse_iterator<const_iterator> const_reverse_iterator

Definition at line 128 of file array.hpp.

Constructor & Destructor Documentation

◆ Array() [1/9]

Array ( )

creates the array with size 0

Definition at line 57 of file array.hpp.

◆ Array() [2/9]

Array ( Size  size)
explicit

creates the array with the given dimension

Definition at line 267 of file array.hpp.

◆ Array() [3/9]

Array ( Size  size,
Real  value 
)

creates the array and fills it with value

Definition at line 270 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [4/9]

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 275 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [5/9]

Array ( const Array from)

Definition at line 281 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [6/9]

Array ( Array &&  from)
noexcept

Definition at line 287 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [7/9]

Array ( std::initializer_list< Real init)

Definition at line 329 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [8/9]

Array ( std::initializer_list< T init)

Definition at line 343 of file array.hpp.

+ Here is the call graph for this function:

◆ Array() [9/9]

Array ( ForwardIterator  begin,
ForwardIterator  end 
)

creates the array from an iterable sequence

Definition at line 335 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 347 of file array.hpp.

+ Here is the call graph for this function:

◆ operator=() [2/2]

Array & operator= ( Array &&  from)
noexcept

Definition at line 354 of file array.hpp.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const Array to) const

Definition at line 359 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 363 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+=() [1/2]

const Array & operator+= ( const Array v)

Definition at line 367 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+=() [2/2]

const Array & operator+= ( Real  x)

Definition at line 376 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-=() [1/2]

const Array & operator-= ( const Array v)

Definition at line 381 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-=() [2/2]

const Array & operator-= ( Real  x)

Definition at line 389 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*=() [1/2]

const Array & operator*= ( const Array v)

Definition at line 394 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*=() [2/2]

const Array & operator*= ( Real  x)

Definition at line 402 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/=() [1/2]

const Array & operator/= ( const Array v)

Definition at line 407 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/=() [2/2]

const Array & operator/= ( Real  x)

Definition at line 415 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 423 of file array.hpp.

◆ at() [1/2]

Real at ( Size  i) const

Definition at line 432 of file array.hpp.

+ Here is the caller graph for this function:

◆ front() [1/2]

Real front ( ) const

Definition at line 439 of file array.hpp.

+ Here is the caller graph for this function:

◆ back() [1/2]

Real back ( ) const

Definition at line 446 of file array.hpp.

+ Here is the caller graph for this function:

◆ operator[]() [2/2]

Real & operator[] ( Size  i)

read-write

Definition at line 453 of file array.hpp.

◆ at() [2/2]

Real & at ( Size  i)

Definition at line 462 of file array.hpp.

◆ front() [2/2]

Real & front ( )

Definition at line 469 of file array.hpp.

◆ back() [2/2]

Real & back ( )

Definition at line 476 of file array.hpp.

◆ size()

Size size ( ) const

dimension of the array

Examples
GlobalOptimizer.cpp.

Definition at line 483 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 487 of file array.hpp.

+ Here is the caller graph for this function:

◆ begin() [1/2]

Array::const_iterator begin ( ) const

Definition at line 491 of file array.hpp.

+ Here is the caller graph for this function:

◆ begin() [2/2]

Array::iterator begin ( )

Definition at line 495 of file array.hpp.

◆ end() [1/2]

Array::const_iterator end ( ) const

Definition at line 499 of file array.hpp.

+ Here is the caller graph for this function:

◆ end() [2/2]

Array::iterator end ( )

Definition at line 503 of file array.hpp.

◆ rbegin() [1/2]

Definition at line 507 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 511 of file array.hpp.

+ Here is the call graph for this function:

◆ rend() [1/2]

Definition at line 515 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 519 of file array.hpp.

+ Here is the call graph for this function:

◆ resize()

void resize ( Size  n)

Definition at line 523 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 534 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 541 of file array.hpp.

+ Here is the call graph for this function:

◆ Norm2()

Real Norm2 ( const Array )
related

Definition at line 548 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [1/10]

Array operator+ ( const Array v)
related

Definition at line 556 of file array.hpp.

◆ operator+() [2/10]

Array operator+ ( Array &&  v)
related

Definition at line 561 of file array.hpp.

◆ operator-() [1/10]

Array operator- ( const Array v)
related

Definition at line 565 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [2/10]

Array operator- ( Array &&  v)
related

Definition at line 571 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 579 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [4/10]

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

Definition at line 588 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [5/10]

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

Definition at line 597 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [6/10]

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

Definition at line 606 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [7/10]

Array operator+ ( const Array ,
Real   
)
related

Definition at line 615 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [8/10]

Array operator+ ( Array &&  ,
Real   
)
related

Definition at line 621 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [9/10]

Array operator+ ( Real  ,
const Array  
)
related

Definition at line 627 of file array.hpp.

+ Here is the call graph for this function:

◆ operator+() [10/10]

Array operator+ ( Real  ,
Array &&   
)
related

Definition at line 633 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 639 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [4/10]

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

Definition at line 648 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [5/10]

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

Definition at line 657 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [6/10]

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

Definition at line 666 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [7/10]

Array operator- ( const Array ,
Real   
)
related

Definition at line 675 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [8/10]

Array operator- ( Real  ,
const Array  
)
related

Definition at line 687 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [9/10]

Array operator- ( Array &&  ,
Real   
)
related

Definition at line 681 of file array.hpp.

+ Here is the call graph for this function:

◆ operator-() [10/10]

Array operator- ( Real  ,
Array &&   
)
related

Definition at line 693 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 699 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [2/8]

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

Definition at line 708 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [3/8]

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

Definition at line 717 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [4/8]

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

Definition at line 726 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [5/8]

Array operator* ( const Array ,
Real   
)
related

Definition at line 735 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [6/8]

Array operator* ( Real  ,
const Array  
)
related

Definition at line 747 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [7/8]

Array operator* ( Array &&  ,
Real   
)
related

Definition at line 741 of file array.hpp.

+ Here is the call graph for this function:

◆ operator*() [8/8]

Array operator* ( Real  ,
Array &&   
)
related

Definition at line 753 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 759 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [2/8]

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

Definition at line 768 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [3/8]

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

Definition at line 777 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [4/8]

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

Definition at line 786 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [5/8]

Array operator/ ( const Array ,
Real   
)
related

Definition at line 795 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [6/8]

Array operator/ ( Real  ,
const Array  
)
related

Definition at line 807 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [7/8]

Array operator/ ( Array &&  ,
Real   
)
related

Definition at line 801 of file array.hpp.

+ Here is the call graph for this function:

◆ operator/() [8/8]

Array operator/ ( Real  ,
Array &&   
)
related

Definition at line 813 of file array.hpp.

+ Here is the call graph for this function:

◆ Abs() [1/2]

Array Abs ( const Array )
related

Definition at line 821 of file array.hpp.

+ Here is the call graph for this function:

◆ Abs() [2/2]

Array Abs ( Array &&  )
related

Definition at line 828 of file array.hpp.

+ Here is the call graph for this function:

◆ Sqrt() [1/2]

Array Sqrt ( const Array )
related

Definition at line 835 of file array.hpp.

+ Here is the call graph for this function:

◆ Sqrt() [2/2]

Array Sqrt ( Array &&  )
related

Definition at line 842 of file array.hpp.

+ Here is the call graph for this function:

◆ Log() [1/2]

Array Log ( const Array )
related

Definition at line 849 of file array.hpp.

+ Here is the call graph for this function:

◆ Log() [2/2]

Array Log ( Array &&  )
related

Definition at line 856 of file array.hpp.

+ Here is the call graph for this function:

◆ Exp() [1/2]

Array Exp ( const Array )
related

Definition at line 863 of file array.hpp.

+ Here is the call graph for this function:

◆ Exp() [2/2]

Array Exp ( Array &&  )
related

Definition at line 870 of file array.hpp.

+ Here is the call graph for this function:

◆ Pow() [1/2]

Array Pow ( const Array ,
Real   
)
related

Definition at line 877 of file array.hpp.

+ Here is the call graph for this function:

◆ Pow() [2/2]

Array Pow ( Array &&  ,
Real   
)
related

Definition at line 884 of file array.hpp.

+ Here is the call graph for this function:

◆ swap()

void swap ( Array ,
Array  
)
related

Definition at line 891 of file array.hpp.

◆ operator<<()

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

Definition at line 895 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 147 of file array.hpp.

◆ n_

Size n_
private

Definition at line 148 of file array.hpp.