openGPMP
Open Source Mathematics Package
Public Member Functions | List of all members
gpmp::Arith< T > Class Template Reference

Arithmetic Basics More...

#include <arithmetic.hpp>

Public Member Functions

arr_add (T arr[], int64_t n)
 
arr_sub (T arr[], int64_t n)
 
arr_mlt (T arr[], int64_t n)
 

Detailed Description

template<typename T>
class gpmp::Arith< T >

Arithmetic Basics

Basics of Arithmetic

Arithmetic Template Class. Each method is variadic taking 'n' params.

Examples
arithmetic.cpp.

Definition at line 66 of file arithmetic.hpp.

Member Function Documentation

◆ arr_add()

template<typename T >
T gpmp::Arith< T >::arr_add ( arr[],
int64_t  n 
)
inline
Examples
arithmetic.cpp.

Definition at line 68 of file arithmetic.hpp.

68  {
69  T sum = 0;
70 
71  for (int64_t i = 0; i < n; i++) {
72  sum += arr[i];
73  }
74  return sum;
75  }

Referenced by main().

◆ arr_mlt()

template<typename T >
T gpmp::Arith< T >::arr_mlt ( arr[],
int64_t  n 
)
inline
Examples
arithmetic.cpp.

Definition at line 86 of file arithmetic.hpp.

86  {
87  T prod = arr[0];
88 
89  for (int64_t i = 0; i < n; i++) {
90  prod *= arr[i];
91  }
92  return prod;
93  }

Referenced by main().

◆ arr_sub()

template<typename T >
T gpmp::Arith< T >::arr_sub ( arr[],
int64_t  n 
)
inline
Examples
arithmetic.cpp.

Definition at line 77 of file arithmetic.hpp.

77  {
78  T diff = arr[0];
79 
80  for (int64_t i = 1; i < n; i++) {
81  diff -= arr[i];
82  }
83  return diff;
84  }

Referenced by main().


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