23 #ifndef NUMERICAL_H_INCLUDED 24 #define NUMERICAL_H_INCLUDED 45 std::ostream &out = std::cout
48 std::vector<Parent> getSubSymbols()
const override;
51 std::optional<Expr>
getTerm()
const override;
94 explicit Integer(
long long int t_value);
110 void setValue(
long double t_value)
override;
112 void print(
int mode=0,
113 std::ostream& out=std::cout,
114 bool lib =
false)
const override;
116 std::string
printLaTeX(
int mode=0)
const override;
121 csl::eval::mode user_mode = csl::eval::base
124 unique_Expr copy_unique()
const override;
185 explicit Float(
long double t_value);
188 ~
Float(){ __record_data_alloc(static_cast<int>(
getType())); }
202 void setValue(
long double t_value)
override;
204 void print(
int mode=0,
205 std::ostream& out=std::cout,
206 bool lib =
false)
const override;
208 std::string
printLaTeX(
int mode=0)
const override;
213 csl::eval::mode user_mode = csl::eval::base
216 unique_Expr copy_unique()
const override;
218 Expr refresh()
const override;
290 IntFraction(
long long int t_num,
long long int t_denom);
306 long long int getNum()
const override;
311 long long int getDenom()
const override;
313 void print(
int mode=0,
314 std::ostream& out=std::cout,
315 bool lib =
false)
const override;
319 std::ostream &out = std::cout
322 std::string
printLaTeX(
int mode=0)
const override;
330 csl::eval::mode user_mode = csl::eval::base
333 unique_Expr copy_unique()
const override;
335 Expr refresh()
const override;
432 void print(
int mode=0,
433 std::ostream& out=std::cout,
434 bool lib =
false)
const override;
438 std::ostream& out=std::cout
441 std::string
printLaTeX(
int mode=0)
const override;
446 csl::eval::mode user_mode = csl::eval::base
449 bool isReal()
const override;
451 bool isPurelyImaginary()
const override;
463 unique_Expr copy_unique()
const override;
465 Expr refresh()
const override;
483 void checkNumerical(
Expr const& expr)
const;
487 Expr float_s(
long double value);
489 Expr int_s(
long long int value);
491 Expr autonumber_s(
long double value);
493 Expr intfraction_s(
long long int num,
long long int denom);
497 inline csl::allocator<Integer> alloc_integer;
498 inline csl::allocator<Float> alloc_float;
499 inline csl::allocator<IntFraction> alloc_intfraction;
500 inline csl::allocator<Complex> alloc_complex;
504 inline const csl::Expr CSL_0 = csl::make_shared<csl::Integer>(0);
506 inline const csl::Expr CSL_1 = csl::make_shared<csl::Integer>(1);
508 inline const csl::Expr CSL_2 = csl::make_shared<csl::Integer>(2);
510 inline const csl::Expr CSL_M_1 = csl::make_shared<csl::Integer>(-1);
512 inline const csl::Expr CSL_M_2 = csl::make_shared<csl::Integer>(-2);
514 inline const csl::Expr CSL_HALF = csl::make_shared<csl::IntFraction>(1, 2);
516 inline const csl::Expr CSL_THIRD = csl::make_shared<csl::IntFraction>(1, 3);
518 inline const csl::Expr CSL_M_HALF = csl::make_shared<csl::IntFraction>(-1, 2);
520 inline const csl::Expr CSL_M_THIRD = csl::make_shared<csl::IntFraction>(-1, 3);
virtual Expr addition_own(const Expr &expr) const
Contains implementation of special addition for Numerical- and Vectorial-types.
Definition: abstract.cpp:878
Expr multiplication_own(const Expr &expr, bool side=1) const override
Multiplicates the IntFraction with a Number or a IntFraction.
Definition: numerical.cpp:631
Expr addition_own(const Expr &expr) const override
Adds the IntFraction with a Number or a IntFraction.
Definition: numerical.cpp:654
virtual bool operator<(Expr_info expr) const =0
Compares the simplicity of the expression to another.
Namespace for csl library.
Definition: abreviation.h:34
Float()
Default constructor. expanded = CSL_0;.
Definition: numerical.h:388
std::string printLaTeX(int mode=0) const override
Creates a LaTeX output for the Abstract.
Definition: numerical.cpp:595
Abstract class from which derive all building blocks of exprs, i.e. objects not function of further e...
Definition: buildingBlock.h:34
Expr imag
Definition: numerical.h:402
bool operator==(Expr_info expr) const override
Compares the Abstract with another.
Definition: numerical.cpp:735
Expr exponentiation_own(const Expr &expr) const override
Contains implementation of special exponentiation for Numerical- and Vectorial-types.
Definition: numerical.cpp:701
Type
Enum of the different types of Abstract (i.e. list of all possible specializations).
Definition: enum.h:47
virtual long double evaluateScalar() const
Evaluates the value of the Abstract.
Definition: abstract.cpp:871
IntFraction()
Default Constructor.
Definition: numerical.h:392
virtual void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const =0
Displays the abstract in standard output.
Expr division_own(const Expr &expr) const override
Contains implementation of special division for Numerical- and Polynomial-types. For polynomial...
Definition: numerical.cpp:676
void print(int mode=0, std::ostream &out=std::cout, bool lib=false) const override
Displays the abstract in standard output.
Definition: numerical.cpp:562
std::optional< Expr > getComplexModulus() const override
Evaluates the modulus in the complex plane of the Abstract and returns it.
Definition: buildingBlock.cpp:53
virtual long long int getNum() const
Definition: abstract.cpp:187
csl::PrimaryType getPrimaryType() const override
Gives the primary type of Abstract.
Definition: numerical.h:39
Definition: numerical.h:396
virtual Expr exponentiation_own(const Expr &expr) const
Contains implementation of special exponentiation for Numerical- and Vectorial-types.
Definition: abstract.cpp:899
long long int value
Value of the number.
Definition: numerical.h:82
bool dependsOn(Expr_info) const override
Check recursively if the expression depends on expr.
Definition: numerical.h:53
virtual std::optional< Expr > getComplexArgument() const
Evaluates the argument in the complex plane of the Abstract and returns it.
Definition: abstract.cpp:677
virtual void operator=(double t_value)
Equivalent to the setValue() function.
Definition: abstract.cpp:972
std::optional< Expr > getTerm() const override
This function returns the same expression as *this but amputated of its numerical factor...
Definition: numerical.cpp:60
virtual long long int getDenom() const
Definition: abstract.cpp:192
Expr getNumericalFactor() const override
Returns the numerical factor of the expression, i.e. returns C if the expression if of the form C*x (...
Definition: numerical.cpp:55
virtual bool operator==(int t_value) const
Definition: abstract.cpp:988
virtual void setValue(long double t_value)
Sets the value if there is one (for Numerical and Literal valued).
Definition: abstract.cpp:794
PrimaryType
Stores enumerations of types for Abstract objects.
Definition: enum.h:31
std::optional< Expr > getRealPart() const override
Evaluates the real part of the Abstract and returns it.
Definition: buildingBlock.cpp:49
bool dependsExplicitlyOn(Expr_info) const override
Check recursively if expr is present in the expression.
Definition: numerical.h:59
bool isInteger() const override
Tells if the expression is an integer. Either an Integer object directly, or a Float that has an inte...
Definition: numerical.h:105
Handle numbers in expr.
Definition: numerical.h:168
std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const override
Evaluates the Abstract.
Definition: numerical.cpp:612
long long int num
Definition: numerical.h:271
long long int denom
Definition: numerical.h:272
Root class of the inheritance tree of abstracts.
Definition: abstract.h:76
Expr real
Definition: numerical.h:400
long double evaluateScalar() const override
Evaluates the IntFraction.
Definition: numerical.cpp:608
Base class for all parents (indicial, fields etc). All parents derive from this class.
Definition: parent.h:81
Integer()
Default constructor.
Definition: numerical.h:383
virtual bool isInteger() const
Tells if the expression is an integer. Either an Integer object directly, or a Float that has an inte...
Definition: abstract.cpp:568
csl::Type getType() const override
Gives the type of a IntFraction.
Definition: numerical.cpp:552
virtual Expr multiplication_own(const Expr &expr, bool side=1) const
Contains implementation of special multiplication for Numerical- and Vectorial-types.
Definition: abstract.cpp:885
Abstract class from which derive numerical types, i.e. Float, Integer, IntFraction.
Definition: numerical.h:34
virtual Expr getImaginaryPart() const
Evaluates the imaginary part of the Abstract and returns it.
Definition: abstract.cpp:667
virtual std::string printLaTeX(int mode=0) const
Creates a LaTeX output for the Abstract.
Definition: abstract.cpp:168
long double value
Value of the number.
Definition: numerical.h:172
Handle numbers in expr.
Definition: numerical.h:78
virtual csl::Type getType() const =0
Gives the type of Abstract.
Handles fractions of Number.
Definition: numerical.h:267
virtual Expr division_own(const Expr &expr) const
Contains implementation of special division for Numerical- and Polynomial-types. For polynomial...
Definition: abstract.cpp:892
bool operator<(const Expr &a, const Expr &b)
see Abstract::operator<()
Definition: abstract.cpp:1423
std::optional< Expr > derive(Expr_info expr) const override
Derives the IntFraction wrt the argument.
Definition: numerical.cpp:719
virtual std::optional< Expr > evaluate(csl::eval::mode user_mode=csl::eval::base) const =0
Evaluates the Abstract.
virtual std::optional< Expr > derive(Expr_info expr) const
Calculates the derivative of the Abstract wrt another.
Definition: abstract.cpp:774
virtual std::optional< Expr > getComplexConjugate() const
Calculates and returns the complex conjugate of the expression.
Definition: abstract.cpp:682
Expression type/.
Definition: abstract.h:1573