operations.h
Go to the documentation of this file.
1 
40 #ifndef ARBITRARY_PRECISION_CALCULATION_OPERATIONS_H_
41 #define ARBITRARY_PRECISION_CALCULATION_OPERATIONS_H_
42 
43 #include <gmp.h>
44 #include <string>
45 #include <vector>
46 
48 
50 
54 namespace vectoroperations {
63 std::vector<mpf_t*> Add(const std::vector<mpf_t*> & a, const std::vector<mpf_t*> & b);
72 std::vector<mpf_t*> Subtract(const std::vector<mpf_t*> & a, const std::vector<mpf_t*> & b);
81 std::vector<mpf_t*> Divide(const std::vector<mpf_t*> & a, const std::vector<mpf_t*> & b);
90 std::vector<mpf_t*> Multiply(const std::vector<mpf_t*> & a, const std::vector<mpf_t*> & b);
99 std::vector<mpf_t*> Multiply(const std::vector<mpf_t*> & a, const std::vector<double> & b);
108 std::vector<mpf_t*> Multiply(const std::vector<mpf_t*> & a, const double & b);
117 std::vector<mpf_t*> Multiply(const std::vector<mpf_t*> & a, mpf_t* b);
125 mpf_t* Add(const std::vector<mpf_t*> &a);
134 std::vector<mpf_t*> GetConstantVector(int dimension, const double & value);
143 std::vector<mpf_t*> GetConstantVector(int dimension, const mpf_t* value);
151 std::vector<mpf_t*> GetVector(const std::vector<double> & a);
159 void ReleaseValues(const std::vector<mpf_t*> & a);
169 std::vector<mpf_t*> Clone(const std::vector<mpf_t*> & a);
177 std::vector<mpf_t*> Randomize(const std::vector<mpf_t*> & a);
185 std::vector<mpf_t*> GetRandomVector(int dimensions);
193 std::vector<double> MpftToDouble(const std::vector<mpf_t*> & a);
202 bool Equals(const std::vector<mpf_t*> & a, const std::vector<mpf_t*> & b);
215 std::vector<mpf_t*> OrthogonalProjection(const std::vector<mpf_t*> & vec, const std::vector<mpf_t*> & projection_vector);
223 mpf_t* SquaredEuclideanLength(const std::vector<mpf_t*> & vec);
229 void Sort(std::vector<mpf_t*>* vec);
230 
231 } // namespace vectoroperations
232 
236 namespace mpftoperations {
237 
260 void ChangeNumberOfMpftValuesCached(int change);
276 void IncreasePrecision();
282 mpf_t* GetResultPointer();
291 mpf_t* Add(const mpf_t* a, const mpf_t* b);
300 mpf_t* Subtract(const mpf_t* a, const mpf_t* b);
309 mpf_t* Multiply2Exp(const mpf_t* a, int p);
318 mpf_t* Multiply(const mpf_t* a, const mpf_t* b);
327 mpf_t* Multiply(const mpf_t* a, const double b);
336 mpf_t* Divide(const mpf_t* a, const mpf_t* b);
344 void ReleaseValue(mpf_t* a);
350 mpf_t* GetPi();
356 mpf_t* GetE();
364 mpf_t* Exp(mpf_t* a);
375 int Compare(const mpf_t* a, const mpf_t* b);
386 int Compare(const double a, const mpf_t* b);
397 int Compare(const mpf_t* a, double b);
403 mpf_t* GetPlusInfinity();
409 mpf_t* GetMinusInfinity();
415 mpf_t* GetUndefined();
424 bool IsInfinite(const mpf_t* value);
433 bool IsPlusInfinity(const mpf_t* value);
442 bool IsMinusInfinity(const mpf_t* value);
451 bool IsUndefined(const mpf_t* value);
459 mpf_t* Sin(mpf_t* x);
467 mpf_t* Cos(mpf_t* x);
475 mpf_t* Tan(mpf_t* x);
483 mpf_t* Arcsin(mpf_t* x);
491 mpf_t* Arccos(mpf_t* x);
499 mpf_t* Arctan(mpf_t* x);
507 mpf_t* ToMpft(double value);
515 mpf_t* ToMpft(long long value);
523 mpf_t* ToMpft(unsigned long long value);
531 mpf_t* ToMpft(int value);
539 mpf_t* ToMpft(unsigned int value);
547 mpf_t* Abs(const mpf_t* x);
555 mpf_t* Negate(const mpf_t* x);
565 mpf_t* Clone(const mpf_t* value);
574 mpf_t* Max(mpf_t* a, mpf_t* b);
583 mpf_t* Min(mpf_t* a, mpf_t* b);
593 mpf_t* Floor(mpf_t* value);
603 mpf_t* Ceil(mpf_t* value);
611 mpf_t* GetRandomMpft(RandomNumberGenerator* random);
617 mpf_t* GetRandomMpft();
627 mpf_t* GetGaussianRandomMpft(double mu, double sigma, RandomNumberGenerator* random);
636 mpf_t* GetGaussianRandomMpft(double mu, double sigma);
644 mpf_t* Randomize(mpf_t* value);
653 mpf_t* Randomize(mpf_t* value, RandomNumberGenerator* random);
661 double MpftToDouble(mpf_t* value);
670 mpf_t* Pow(mpf_t* value, int exponent);
679 mpf_t* Pow(mpf_t* value, double exponent);
688 mpf_t* Pow(mpf_t* value, mpf_t* exponent);
696 mpf_t* Sqrt(mpf_t* value);
704 mpf_t* LogE(mpf_t* value);
712 double Log2Double(mpf_t* value);
713 
721 std::string MpftToString(const mpf_t* value);
722 
729 void StoreMpft(mpf_t* value, std::ofstream* stream);
737 mpf_t* LoadMpft(std::ifstream* stream);
738 
739 } // namespace mpftoperations
740 } // namespace arbitraryprecisioncalculation
741 
742 #endif /* ARBITRARY_PRECISION_CALCULATION_OPERATIONS_H_ */
mpf_t * Negate(const mpf_t *x)
Calculates the negation of the supplied value.
mpf_t * Ceil(mpf_t *value)
Calculates the smallest integral value greater or equal than the supplied value.
mpf_t * Floor(mpf_t *value)
Calculates the largest integral value less or equal than the supplied value.
void ChangeNumberOfMpftValuesCached(int change)
Changes the number of mpf_t values currently in cache by the specified number.
mpf_t * GetGaussianRandomMpft(double mu, double sigma)
Calculates a random value with normal distribution (gaussian distribution).
mpf_t * Min(mpf_t *a, mpf_t *b)
Calculates the minimum of the two values.
int GetNumberOfMpftValuesCached()
Getter function for the number of mpf_t values which are currently cached.
mpf_t * Multiply2Exp(const mpf_t *a, int p)
Multiplies the value of parameter a by a factor of 2p.
std::string MpftToString(const mpf_t *value)
Converts an mpf_t value to a string representation of it.
std::vector< mpf_t * > Divide(const std::vector< mpf_t * > &a, const std::vector< mpf_t * > &b)
Performs element wise division of the two vectors.
std::vector< mpf_t * > Add(const std::vector< mpf_t * > &a, const std::vector< mpf_t * > &b)
Performs element wise addition of the two vectors.
std::vector< mpf_t * > Multiply(const std::vector< mpf_t * > &a, const std::vector< mpf_t * > &b)
Performs element wise multiplication of the two vectors.
mpf_t * Cos(mpf_t *x)
Calculates the cosine function of the supplied value.
bool IsUndefined(const mpf_t *value)
Checks whether the supplied value is the representation of an undefined value.
mpf_t * Tan(mpf_t *x)
Calculates the tangent function of the supplied value.
mpf_t * GetE()
Calculates the value of E.
This file contains the available random number generators.
int Compare(const mpf_t *a, double b)
Compares the two parameters.
std::vector< mpf_t * > Clone(const std::vector< mpf_t * > &a)
Creates a copy of the supplied vector where each entry is cloned.
mpf_t * LoadMpft(std::ifstream *stream)
Recovers a mpf_t value from an input stream.
std::vector< mpf_t * > GetVector(const std::vector< double > &a)
Transforms the vector with double entries to a vector with mpf_t* values.
bool Equals(const std::vector< mpf_t * > &a, const std::vector< mpf_t * > &b)
Checks whether two mpf_t* vectors are equal.
mpf_t * GetPlusInfinity()
Calculates the representation of +infinity.
double Log2Double(mpf_t *value)
Calculates the base 2 logarithm of the specified value.
std::vector< mpf_t * > GetRandomVector(int dimensions)
Creates a random mpf_t* vector with the specified number of entries, which contains random values in ...
bool IsPlusInfinity(const mpf_t *value)
Checks whether the supplied value is the representation of +infinity.
void ReleaseValue(mpf_t *a)
Releases the reserved memory for the supplied mpf_t.
void IncreasePrecision()
Increases the precision instantly to a higher value.
mpf_t * SquaredEuclideanLength(const std::vector< mpf_t * > &vec)
Calculates the squared euclidean length of the supplied vector.
mpf_t * Sqrt(mpf_t *value)
Calculates the square root of the specified value.
int GetNumberOfMpftValuesInUse()
Getter function for the number of mpf_t values which are currently in use.
mpf_t * GetResultPointer()
Prepares an mpf_t value for using it.
base namespace for arbitrary precision calculation.
Definition: check_condition.h:45
mpf_t * GetRandomMpft()
Calculates a random mpf_t value in the range [0,1] with the specified standard random number generato...
bool IsInfinite(const mpf_t *value)
Checks whether the supplied value is the representation of +infinity or -infinity.
void ReleaseValues(const std::vector< mpf_t * > &a)
Release the reserved memory for the entries of the supplied vector.
mpf_t * Abs(const mpf_t *x)
Calculates the absolute value of the supplied value.
std::vector< mpf_t * > OrthogonalProjection(const std::vector< mpf_t * > &vec, const std::vector< mpf_t * > &projection_vector)
Calculates the orthogonal projection of the vector vec on the projection vector.
bool IsMinusInfinity(const mpf_t *value)
Checks whether the supplied value is the representation of -infinity.
mpf_t * ToMpft(unsigned int value)
Converts the supplied unsigned int value to its mpf_t representation.
mpf_t * Arctan(mpf_t *x)
Calculates the arctangent function of the supplied value.
mpf_t * Exp(mpf_t *a)
Calculates the exponential function of the input.
void StatisticalCalculationsEnd()
Signals the end of statistical calculations.
std::vector< mpf_t * > Randomize(const std::vector< mpf_t * > &a)
Randomizes the supplied vector. Each entry will be multiplied by a random mpf_t value in the interval...
mpf_t * GetMinusInfinity()
Calculates the representation of -infinity.
This class is an abstract class. It supplies the interface for random number generators.
Definition: random_number_generator.h:52
void Sort(std::vector< mpf_t * > *vec)
Sorts the elements of the supplied vector in increasing order.
mpf_t * Max(mpf_t *a, mpf_t *b)
Calculates the maximum of the two values.
mpf_t * GetPi()
Calculates the value of Pi.
std::vector< mpf_t * > Subtract(const std::vector< mpf_t * > &a, const std::vector< mpf_t * > &b)
Performs element wise subtraction of the two vectors.
std::vector< mpf_t * > GetConstantVector(int dimension, const double &value)
Creates a vector with the specified number of entries. Each entry represents the supplied value...
mpf_t * Arccos(mpf_t *x)
Calculates the arccosine function of the supplied value.
mpf_t * GetUndefined()
Calculates the representation of an undefined value.
mpf_t * Pow(mpf_t *value, mpf_t *exponent)
Calculates the value to the power of the specified exponent.
mpf_t * Arcsin(mpf_t *x)
Calculates the arcsine function of the supplied value.
mpf_t * LogE(mpf_t *value)
Calculates the base E logarithm of the specified value.
mpf_t * Sin(mpf_t *x)
Calculates the sine function of the supplied value.
void StoreMpft(mpf_t *value, std::ofstream *stream)
Writes the content of a mpf_t value to the given stream such that it can completely recovered...
std::vector< double > MpftToDouble(const std::vector< mpf_t * > &a)
Converts the values of a vector with mpf_t* entries to a vector with double entries.
void StatisticalCalculationsStart()
Signals the start of statistical calculations.