SymEngine Namespace Reference

Main namespace for SymEngine package. More...

Data Structures

class  Add
 The base class for representing addition in symbolic expressions. More...
 
class  RealImagVisitor
 
class  Assumptions
 
class  Basic
 The lowest unit of symbolic representation. More...
 
struct  RCPBasicHash
 Our hash: More...
 
struct  RCPBasicKeyEq
 Our comparison (==) More...
 
struct  RCPBasicKeyLess
 Our less operator (<): More...
 
class  ComplexBase
 ComplexBase Class for deriving all complex classes. More...
 
class  Complex
 Complex Class. More...
 
class  ComplexDouble
 Complex Double Class to hold std::complex<double> values. More...
 
class  ComplexMPC
 
class  Constant
 
class  FuncArgTracker
 
class  OptsCSEVisitor
 
class  RebuildVisitor
 
class  DiffVisitor
 
struct  vec_hash
 
class  EvalVisitor
 
class  EvalDoubleVisitor
 
class  EvalRealDoubleVisitor
 
class  EvalRealDoubleVisitorPattern
 
class  EvalRealDoubleVisitorFinal
 
class  EvalComplexDoubleVisitor
 
class  ExpandVisitor
 
class  Expression
 
class  GaloisFieldDict
 
class  GaloisField
 
class  fmpz_wrapper
 
class  mpz_view_flint
 
class  fmpq_wrapper
 
class  mpq_view_flint
 
class  fmpz_poly_factor_wrapper
 
class  fmpz_poly_wrapper
 
class  fmpq_poly_wrapper
 
class  Function
 
class  OneArgFunction
 
class  TwoArgBasic
 
class  MultiArgFunction
 
class  Sign
 
class  Floor
 
class  Ceiling
 
class  Truncate
 
class  Conjugate
 
class  TrigBase
 
class  TrigFunction
 
class  InverseTrigFunction
 
class  Sin
 
class  Cos
 
class  Tan
 
class  Cot
 
class  Csc
 
class  Sec
 
class  ASin
 
class  ACos
 
class  ASec
 
class  ACsc
 
class  ATan
 
class  ACot
 
class  ATan2
 
class  Log
 
class  LambertW
 
class  Zeta
 
class  Dirichlet_eta
 
class  FunctionSymbol
 
class  FunctionWrapper
 
class  Derivative
 
class  Subs
 
class  HyperbolicBase
 
class  HyperbolicFunction
 
class  InverseHyperbolicFunction
 
class  Sinh
 
class  Csch
 
class  Cosh
 
class  Sech
 
class  Tanh
 
class  Coth
 
class  ASinh
 
class  ACsch
 
class  ACosh
 
class  ATanh
 
class  ACoth
 
class  ASech
 
class  KroneckerDelta
 
class  LeviCivita
 
class  Erf
 
class  Erfc
 
class  Gamma
 
class  LowerGamma
 
class  UpperGamma
 
class  LogGamma
 
class  Beta
 
class  PolyGamma
 
class  Abs
 
class  Max
 
class  Min
 
class  UnevaluatedExpr
 
class  EvaluateInfty
 
class  Infty
 
class  Integer
 Integer Class. More...
 
struct  RCPIntegerKeyLess
 less operator (<) for Integers More...
 
class  LambdaDoubleVisitor
 
class  LambdaRealDoubleVisitor
 
class  LambdaComplexDoubleVisitor
 
class  IRBuilder
 
class  Boolean
 
class  BooleanAtom
 
class  Contains
 
class  Piecewise
 
class  And
 
class  Or
 
class  Not
 
class  Xor
 
class  Relational
 
class  Equality
 
class  Unequality
 
class  LessThan
 
class  StrictLessThan
 
class  MatrixBase
 
class  DenseMatrix
 
class  CSRMatrix
 
struct  two_by_two_matrix
 
class  mp_randstate
 
class  Mul
 
class  EvaluateNaN
 
class  NaN
 
class  Sieve
 
class  PrimePi
 
class  Number
 
class  NumberWrapper
 
class  Evaluate
 A class that will evaluate functions numerically. More...
 
class  NumerDenomVisitor
 
class  PolyGeneratorVisitor
 
class  PolyGeneratorVisitorPow
 
class  BasicToUPolyBase
 
class  BasicToUIntPoly
 
class  BasicToUExprPoly
 
class  BasicToURatPoly
 
class  BasicToMPolyBase
 
class  BasicToMIntPoly
 
class  BasicToMExprPoly
 
class  UDictWrapper
 
class  MIntDict
 
class  MExprDict
 
class  MSymEnginePoly
 
class  MIntPoly
 
class  MExprPoly
 
class  UExprDict
 
class  UExprPoly
 
class  UIntDict
 
class  UIntPoly
 
class  ODictWrapper
 
class  UPolyBase
 
class  UExprPolyBase
 
class  UNonExprPoly
 
class  UIntPolyBase
 
class  URatPolyBase
 
class  ContainerBaseIter
 
class  ContainerForIter
 
class  ContainerRevIter
 
struct  is_a_UPoly
 
class  URatDict
 
class  URatPoly
 
class  USymEnginePoly
 
class  Pow
 
class  CodePrinter
 
class  C89CodePrinter
 
class  C99CodePrinter
 
class  JSCodePrinter
 
class  LatexPrinter
 
class  MathMLPrinter
 
struct  PrinterBasicCmp
 Less operator (<) using cmp: More...
 
class  Precedence
 
class  StrPrinter
 
class  JuliaStrPrinter
 
class  Rational
 Rational Class. More...
 
class  EvaluateDouble
 Evaluate functions with double precision. More...
 
class  EvaluateRealDouble
 
class  EvaluateComplexDouble
 
class  RealDouble
 RealDouble Class to hold double values. More...
 
class  RealMPFR
 
class  RewriteAsExp
 
class  SeriesCoeffInterface
 
class  SeriesBase
 
class  UnivariateSeries
 UnivariateSeries Class. More...
 
class  SeriesVisitor
 
class  NeedsSymbolicExpansionVisitor
 
class  Set
 
class  EmptySet
 
class  UniversalSet
 
class  FiniteSet
 
class  Interval
 
class  Reals
 
class  Rationals
 
class  Integers
 
class  Union
 
class  Complement
 
class  ConditionSet
 
class  ImageSet
 
class  IsALinearArgTrigVisitor
 
class  InvertComplexVisitor
 
class  XReplaceVisitor
 
class  SubsVisitor
 
class  MSubsVisitor
 
class  SSubsVisitor
 
class  Symbol
 
class  Dummy
 
struct  remove_reference
 
struct  remove_reference< T & >
 
class  EnableRCPFromThis
 
class  ZeroVisitor
 
class  PositiveVisitor
 
class  NonPositiveVisitor
 
class  NegativeVisitor
 
class  NonNegativeVisitor
 
class  RealVisitor
 
class  ComplexVisitor
 
class  PolynomialVisitor
 
class  FreeSymbolsVisitor
 
class  Visitor
 
class  BaseVisitor
 
class  StopVisitor
 
class  LocalStopVisitor
 
class  HasSymbolVisitor
 
class  CoeffVisitor
 
class  TransformVisitor
 
struct  is_base_of_multiple
 
struct  is_base_of_multiple< Derived, First >
 
class  AtomsVisitor
 
class  CountOpsVisitor
 

Typedefs

typedef uint64_t hash_t
 
typedef std::unordered_map< RCP< const Basic >, RCP< const Number >, RCPBasicHash, RCPBasicKeyEqumap_basic_num
 
typedef std::unordered_map< short, RCP< const Basic > > umap_short_basic
 
typedef std::unordered_map< int, RCP< const Basic > > umap_int_basic
 
typedef std::unordered_map< RCP< const Basic >, RCP< const Basic >, RCPBasicHash, RCPBasicKeyEqumap_basic_basic
 
typedef std::unordered_set< RCP< const Basic >, RCPBasicHash, RCPBasicKeyEquset_basic
 
typedef std::vector< int > vec_int
 
typedef std::vector< RCP< const Basic > > vec_basic
 
typedef std::vector< RCP< const Integer > > vec_integer
 
typedef std::vector< unsigned int > vec_uint
 
typedef std::vector< integer_class > vec_integer_class
 
typedef std::vector< RCP< const Symbol > > vec_sym
 
typedef std::set< RCP< const Basic >, RCPBasicKeyLessset_basic
 
typedef std::multiset< RCP< const Basic >, RCPBasicKeyLessmultiset_basic
 
typedef std::map< vec_uint, unsigned long long int > map_vec_uint
 
typedef std::map< vec_uint, integer_class > map_vec_mpz
 
typedef std::map< RCP< const Basic >, RCP< const Number >, RCPBasicKeyLessmap_basic_num
 
typedef std::map< RCP< const Basic >, RCP< const Basic >, RCPBasicKeyLessmap_basic_basic
 
typedef std::map< RCP< const Integer >, unsigned, RCPIntegerKeyLessmap_integer_uint
 
typedef std::map< unsigned, integer_class > map_uint_mpz
 
typedef std::map< unsigned, rational_class > map_uint_mpq
 
typedef std::map< int, Expressionmap_int_Expr
 
typedef std::unordered_map< RCP< const Basic >, unsigned int, RCPBasicHash, RCPBasicKeyEqumap_basic_uint
 
typedef std::vector< std::pair< RCP< const Basic >, RCP< const Basic > > > vec_pair
 
typedef std::unordered_map< vec_uint, integer_class, vec_hash< vec_uint > > umap_uvec_mpz
 
typedef std::unordered_map< vec_int, integer_class, vec_hash< vec_int > > umap_vec_mpz
 
typedef std::unordered_map< vec_int, Expression, vec_hash< vec_int > > umap_vec_expr
 
template<bool B, class T = void>
using enable_if_t = typename std::enable_if< B, T >::type
 
typedef std::function< double(const Basic &)> fn
 
typedef TwoArgBasic< FunctionTwoArgFunction
 
typedef std::set< RCP< const Boolean >, RCPBasicKeyLessset_boolean
 
typedef std::vector< RCP< const Boolean > > vec_boolean
 
typedef std::vector< std::pair< RCP< const Basic >, RCP< const Boolean > > > PiecewiseVec
 
typedef std::vector< std::pair< int, int > > permutelist
 
typedef boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off > integer_class
 
typedef boost::multiprecision::number< boost::multiprecision::cpp_rational_backend, boost::multiprecision::et_off > rational_class
 
typedef std::set< RCP< const Set >, RCPBasicKeyLessset_set
 

Enumerations

enum  TypeID { TypeID_Count }
 
enum  tribool { indeterminate = -1 , trifalse = 0 , tritrue = 1 }
 
enum class  EvalfDomain { Complex = 0 , Real = 1 , Symbolic = 2 }
 
enum class  PrecedenceEnum {
  Relational , Add , Mul , Pow ,
  Atom
}
 

Functions

RCP< const Basicadd (const RCP< const Basic > &a, const RCP< const Basic > &b)
 Adds two objects (safely). More...
 
RCP< const Basicadd (const vec_basic &a)
 Sums the elements of a vector. More...
 
RCP< const Basicsub (const RCP< const Basic > &a, const RCP< const Basic > &b)
 Substracts b from a. More...
 
void as_real_imag (const RCP< const Basic > &x, const Ptr< RCP< const Basic >> &real, const Ptr< RCP< const Basic >> &imag)
 
bool eq (const Basic &a, const Basic &b)
 Checks equality for a and b More...
 
bool neq (const Basic &a, const Basic &b)
 Checks inequality for a and b More...
 
template<class T >
bool is_a (const Basic &b)
 Templatised version to check is_a type. More...
 
template<class T >
bool is_a_sub (const Basic &b)
 
bool is_same_type (const Basic &a, const Basic &b)
 Returns true if a and b are exactly the same type T.
 
bool is_true (tribool x)
 
bool is_false (tribool x)
 
bool is_indeterminate (tribool x)
 
tribool and_tribool (tribool a, tribool b)
 
tribool not_tribool (tribool a)
 
tribool andwk_tribool (tribool a, tribool b)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::Basic &p)
 << Operator More...
 
template<typename T >
void hash_combine_impl (hash_t &seed, const T &v, typename std::enable_if< std::is_base_of< Basic, T >::value >::type *=nullptr)
 Templatised version to combine hash.
 
template<typename T >
void hash_combine_impl (hash_t &seed, const T &v, typename std::enable_if< std::is_integral< T >::value >::type *=nullptr)
 
void hash_combine_impl (hash_t &seed, const std::string &s)
 
void hash_combine_impl (hash_t &seed, const double &s)
 
template<class T >
void hash_combine (hash_t &seed, const T &v)
 
template<typename T >
std::string to_string (const T &value)
 workaround for MinGW bug
 
const char * get_version ()
 
bool is_a_Atom (const Basic &b)
 Returns true if b is an atom. i.e. b.get_args returns an empty vector.
 
RCP< const Basicexpand (const RCP< const Basic > &self, bool deep=true)
 Expands self
 
void as_numer_denom (const RCP< const Basic > &x, const Ptr< RCP< const Basic >> &numer, const Ptr< RCP< const Basic >> &denom)
 
RCP< const Basicrewrite_as_exp (const RCP< const Basic > &x)
 
void cse (vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs)
 
RCP< const Numberpow_number (const Complex &x, unsigned long n)
 
bool is_a_Complex (const Basic &b)
 
RCP< const ComplexDoublecomplex_double (std::complex< double > x)
 
RCP< const Constantconstant (const std::string &name)
 inline version to return Constant
 
umap_basic_basic opt_cse (const vec_basic &exprs)
 
void tree_cse (vec_pair &replacements, vec_basic &reduced_exprs, const vec_basic &exprs, umap_basic_basic &opt_subs)
 
std::vector< unsigned > set_diff (const std::set< unsigned > &a, const std::vector< unsigned > &b)
 
void add_to_sorted_vec (std::vector< unsigned > &vec, unsigned number)
 
void match_common_args (const std::string &func_class, const vec_basic &funcs_, umap_basic_basic &opt_subs)
 
vec_basic set_as_vec (const set_basic &s)
 
template<typename T >
bool is_aligned (T *p, size_t n=alignof(T))
 
static std::string _str (const Basic &a)
 
void jacobian (const DenseMatrix &A, const DenseMatrix &x, DenseMatrix &result, bool diff_cache)
 
void sjacobian (const DenseMatrix &A, const DenseMatrix &x, DenseMatrix &result, bool diff_cache)
 
void diff (const DenseMatrix &A, const RCP< const Symbol > &x, DenseMatrix &result, bool diff_cache)
 
void sdiff (const DenseMatrix &A, const RCP< const Basic > &x, DenseMatrix &result, bool diff_cache)
 
void conjugate_dense (const DenseMatrix &A, DenseMatrix &B)
 
void transpose_dense (const DenseMatrix &A, DenseMatrix &B)
 
void conjugate_transpose_dense (const DenseMatrix &A, DenseMatrix &B)
 
void submatrix_dense (const DenseMatrix &A, DenseMatrix &B, unsigned row_start, unsigned col_start, unsigned row_end, unsigned col_end, unsigned row_step, unsigned col_step)
 
void add_dense_dense (const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C)
 
void add_dense_scalar (const DenseMatrix &A, const RCP< const Basic > &k, DenseMatrix &B)
 
void mul_dense_dense (const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C)
 
void elementwise_mul_dense_dense (const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C)
 
void mul_dense_scalar (const DenseMatrix &A, const RCP< const Basic > &k, DenseMatrix &B)
 
void row_exchange_dense (DenseMatrix &A, unsigned i, unsigned j)
 
void row_mul_scalar_dense (DenseMatrix &A, unsigned i, RCP< const Basic > &c)
 
void row_add_row_dense (DenseMatrix &A, unsigned i, unsigned j, RCP< const Basic > &c)
 
void permuteFwd (DenseMatrix &A, permutelist &pl)
 
void column_exchange_dense (DenseMatrix &A, unsigned i, unsigned j)
 
void pivoted_gaussian_elimination (const DenseMatrix &A, DenseMatrix &B, permutelist &pl)
 
void fraction_free_gaussian_elimination (const DenseMatrix &A, DenseMatrix &B)
 
void pivoted_fraction_free_gaussian_elimination (const DenseMatrix &A, DenseMatrix &B, permutelist &pl)
 
void pivoted_gauss_jordan_elimination (const DenseMatrix &A, DenseMatrix &B, permutelist &pl)
 
void fraction_free_gauss_jordan_elimination (const DenseMatrix &A, DenseMatrix &B)
 
void pivoted_fraction_free_gauss_jordan_elimination (const DenseMatrix &A, DenseMatrix &B, permutelist &pl)
 
unsigned pivot (DenseMatrix &B, unsigned r, unsigned c)
 
void reduced_row_echelon_form (const DenseMatrix &A, DenseMatrix &b, vec_uint &pivot_cols, bool normalize_last)
 
void diagonal_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void back_substitution (const DenseMatrix &U, const DenseMatrix &b, DenseMatrix &x)
 
void forward_substitution (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void fraction_free_gaussian_elimination_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void fraction_free_gauss_jordan_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x, bool pivot)
 
void fraction_free_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void pivoted_LU_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void LDL_solve (const DenseMatrix &A, const DenseMatrix &b, DenseMatrix &x)
 
void fraction_free_LU (const DenseMatrix &A, DenseMatrix &LU)
 
void LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U)
 
void pivoted_LU (const DenseMatrix &A, DenseMatrix &LU, permutelist &pl)
 
void pivoted_LU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &U, permutelist &pl)
 
void fraction_free_LDU (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &D, DenseMatrix &U)
 
void QR (const DenseMatrix &A, DenseMatrix &Q, DenseMatrix &R)
 
void LDL (const DenseMatrix &A, DenseMatrix &L, DenseMatrix &D)
 
void cholesky (const DenseMatrix &A, DenseMatrix &L)
 
bool is_symmetric_dense (const DenseMatrix &A)
 
RCP< const Basicdet_bareis (const DenseMatrix &A)
 
void berkowitz (const DenseMatrix &A, std::vector< DenseMatrix > &polys)
 
RCP< const Basicdet_berkowitz (const DenseMatrix &A)
 
void char_poly (const DenseMatrix &A, DenseMatrix &B)
 
void inverse_fraction_free_LU (const DenseMatrix &A, DenseMatrix &B)
 
void inverse_LU (const DenseMatrix &A, DenseMatrix &B)
 
void inverse_pivoted_LU (const DenseMatrix &A, DenseMatrix &B)
 
void inverse_gauss_jordan (const DenseMatrix &A, DenseMatrix &B)
 
void dot (const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C)
 
void cross (const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &C)
 
RCP< const Seteigen_values (const DenseMatrix &A)
 
void eye (DenseMatrix &A, int k)
 
void diag (DenseMatrix &A, vec_basic &v, int k)
 
void ones (DenseMatrix &A)
 
void zeros (DenseMatrix &A)
 
template<typename T >
static RCP< const Basicfdiff (const T &self, RCP< const Symbol > x, DiffVisitor &visitor)
 
static bool fdiff (const Ptr< RCP< const Basic >> &ret, const Zeta &self, unsigned index)
 
static bool fdiff (const Ptr< RCP< const Basic >> &ret, const UpperGamma &self, unsigned index)
 
static bool fdiff (const Ptr< RCP< const Basic >> &ret, const LowerGamma &self, unsigned index)
 
static bool fdiff (const Ptr< RCP< const Basic >> &ret, const PolyGamma &self, unsigned index)
 
static bool fdiff (const Ptr< RCP< const Basic >> &ret, const Function &self, unsigned index)
 
template<typename P >
static RCP< const Basicdiff_upolyflint (const P &self, const Symbol &x)
 
template<typename Poly , typename Dict >
static RCP< const Basicdiff_upoly (const Poly &self, const Symbol &x)
 
template<typename Container , typename Poly >
static RCP< const Basicdiff_mpoly (const MSymEnginePoly< Container, Poly > &self, const RCP< const Symbol > &x)
 
static RCP< const Symbolget_dummy (const Basic &b, std::string name)
 
RCP< const Basicdiff (const RCP< const Basic > &arg, const RCP< const Symbol > &x, bool cache=true)
 Differentiation w.r.t symbols.
 
RCP< const Basicsdiff (const RCP< const Basic > &arg, const RCP< const Basic > &x, bool cache)
 SymPy style differentiation for non-symbol variables. More...
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::umap_basic_num &d)
 print functions
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::map_basic_num &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::map_basic_basic &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::umap_basic_basic &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::vec_basic &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::set_basic &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::map_int_Expr &d)
 
std::ostreamoperator<< (std::ostream &out, const SymEngine::vec_pair &d)
 
bool vec_basic_eq_perm (const vec_basic &a, const vec_basic &b)
 misc functions
 
template<typename T1 , typename T2 , typename T3 >
void insert (T1 &m, const T2 &first, const T3 &second)
 
template<class M , typename C = std::less<typename M::key_type>>
std::vector< typename M::key_type > sorted_keys (const M &d)
 
template<typename T , typename U >
bool unified_eq (const std::pair< T, U > &a, const std::pair< T, U > &b)
 
template<typename T , typename U >
bool unified_eq (const std::set< T, U > &a, const std::set< T, U > &b)
 
template<typename T , typename U >
bool unified_eq (const std::multiset< T, U > &a, const std::multiset< T, U > &b)
 
template<typename K , typename V , typename C >
bool unified_eq (const std::map< K, V, C > &a, const std::map< K, V, C > &b)
 
template<typename K , typename V , typename H , typename E >
bool unified_eq (const std::unordered_map< K, V, H, E > &a, const std::unordered_map< K, V, H, E > &b)
 
template<typename T , typename U , typename = enable_if_t<std::is_base_of<Basic, T>::value and std::is_base_of<Basic, U>::value>>
bool unified_eq (const RCP< const T > &a, const RCP< const U > &b)
 
template<typename T , typename = enable_if_t<std::is_arithmetic<T>::value or std::is_same<T, integer_class>::value>>
bool unified_eq (const T &a, const T &b)
 
template<class T >
bool unordered_eq (const T &a, const T &b)
 
template<class T >
bool ordered_eq (const T &A, const T &B)
 
template<typename T >
bool unified_eq (const std::vector< T > &a, const std::vector< T > &b)
 
template<typename T , typename = enable_if_t<std::is_arithmetic<T>::value or std::is_same<T, integer_class>::value or std::is_same<T, rational_class>::value>>
int unified_compare (const T &a, const T &b)
 
template<typename T , typename U , typename = enable_if_t<std::is_base_of<Basic, T>::value and std::is_base_of<Basic, U>::value>>
int unified_compare (const RCP< const T > &a, const RCP< const U > &b)
 
template<class T >
int ordered_compare (const T &A, const T &B)
 
template<typename T >
int unified_compare (const std::vector< T > &a, const std::vector< T > &b)
 
template<typename T , typename U >
int unified_compare (const std::set< T, U > &a, const std::set< T, U > &b)
 
template<typename T , typename U >
int unified_compare (const std::multiset< T, U > &a, const std::multiset< T, U > &b)
 
template<typename T , typename U >
int unified_compare (const std::pair< T, U > &a, const std::pair< T, U > &b)
 
template<typename K , typename V , typename C >
int unified_compare (const std::map< K, V, C > &a, const std::map< K, V, C > &b)
 
template<typename K , typename V , typename H , typename E >
int unified_compare (const std::unordered_map< K, V, H, E > &a, const std::unordered_map< K, V, H, E > &b)
 
template<class M , typename C = std::less<typename M::key_type>>
int unordered_compare (const M &a, const M &b)
 
bool order (const DenseMatrix &t, const std::vector< DenseMatrix > &basis, unsigned k)
 
bool is_minimum (const DenseMatrix &t, const std::vector< DenseMatrix > &basis, unsigned n)
 
void homogeneous_lde (std::vector< DenseMatrix > &basis, const DenseMatrix &A)
 
RCP< const Numberevalf_numeric (const Basic &b, unsigned long bits, bool real)
 
RCP< const Basicevalf (const Basic &b, unsigned long bits, EvalfDomain domain)
 
std::vector< fninit_eval_double ()
 
double eval_double (const Basic &b)
 
std::complex< double > eval_complex_double (const Basic &b)
 
double eval_double_single_dispatch (const Basic &b)
 
double eval_double_visitor_pattern (const Basic &b)
 
RCP< const Number_mulnum (const RCP< const Number > &x, const RCP< const Number > &y)
 
void _imulnum (const Ptr< RCP< const Number >> &self, const RCP< const Number > &other)
 
Expression pow (const Expression &base, const Expression &exp)
 
Expression expand (const Expression &arg)
 
bool unified_eq (const Expression &a, const Expression &b)
 
int unified_compare (const Expression &a, const Expression &b)
 
RCP< const GaloisFieldgf_poly (RCP< const Basic > i, GaloisFieldDict &&dict)
 
RCP< const GaloisFieldgf_poly (RCP< const Basic > i, map_uint_mpz &&dict, integer_class modulo_)
 
RCP< const GaloisFieldpow_upoly (const GaloisField &a, unsigned int p)
 
vec_basic generate_fdiff_weights_vector (const vec_basic &grid, const unsigned max_deriv, const RCP< const Basic > around)
 
RCP< const Basicsqrt (RCP< const Basic > &arg)
 
RCP< const Basiccbrt (RCP< const Basic > &arg)
 
RCP< const Basicconjugate (const RCP< const Basic > &arg)
 Canonicalize Conjugate.
 
bool get_pi_shift (const RCP< const Basic > &arg, const Ptr< RCP< const Number >> &n, const Ptr< RCP< const Basic >> &x)
 
bool trig_has_basic_shift (const RCP< const Basic > &arg)
 
bool could_extract_minus (const Basic &arg)
 
bool handle_minus (const RCP< const Basic > &arg, const Ptr< RCP< const Basic >> &rarg)
 
bool trig_simplify (const RCP< const Basic > &arg, unsigned period, bool odd, bool conj_odd, const Ptr< RCP< const Basic >> &rarg, int &index, int &sign)
 
bool inverse_lookup (umap_basic_basic &d, const RCP< const Basic > &t, const Ptr< RCP< const Basic >> &index)
 
RCP< const Basicsign (const RCP< const Basic > &arg)
 Canonicalize Sign.
 
RCP< const Basicfloor (const RCP< const Basic > &arg)
 Canonicalize Floor:
 
RCP< const Basicceiling (const RCP< const Basic > &arg)
 Canonicalize Ceiling:
 
RCP< const Basictruncate (const RCP< const Basic > &arg)
 Canonicalize Truncate:
 
RCP< const Basicsin (const RCP< const Basic > &arg)
 Canonicalize Sin:
 
RCP< const Basiccos (const RCP< const Basic > &arg)
 Canonicalize Cos:
 
RCP< const Basictan (const RCP< const Basic > &arg)
 Canonicalize Tan:
 
RCP< const Basiccot (const RCP< const Basic > &arg)
 Canonicalize Cot:
 
RCP< const Basiccsc (const RCP< const Basic > &arg)
 Canonicalize Csc:
 
RCP< const Basicsec (const RCP< const Basic > &arg)
 Canonicalize Sec:
 
RCP< const Basictrig_to_sqrt (const RCP< const Basic > &arg)
 
RCP< const Basicasin (const RCP< const Basic > &arg)
 Canonicalize ASin:
 
RCP< const Basicacos (const RCP< const Basic > &arg)
 Canonicalize ACos:
 
RCP< const Basicasec (const RCP< const Basic > &arg)
 Canonicalize ASec:
 
RCP< const Basicacsc (const RCP< const Basic > &arg)
 Canonicalize ACsc:
 
RCP< const Basicatan (const RCP< const Basic > &arg)
 Canonicalize ATan:
 
RCP< const Basicacot (const RCP< const Basic > &arg)
 Canonicalize ACot:
 
RCP< const Basicatan2 (const RCP< const Basic > &num, const RCP< const Basic > &den)
 Canonicalize ATan2:
 
RCP< const Basiclog (const RCP< const Basic > &arg)
 Returns the Natural Logarithm from argument arg
 
RCP< const Basiclog (const RCP< const Basic > &arg, const RCP< const Basic > &base)
 
RCP< const Basiclambertw (const RCP< const Basic > &arg)
 Create a new LambertW instance:
 
RCP< const Basicfunction_symbol (std::string name, const vec_basic &arg)
 
RCP< const Basicfunction_symbol (std::string name, const RCP< const Basic > &arg)
 Create a new FunctionSymbol instance:
 
RCP< const Basicsinh (const RCP< const Basic > &arg)
 Canonicalize Sinh:
 
RCP< const Basiccsch (const RCP< const Basic > &arg)
 Canonicalize Csch:
 
RCP< const Basiccosh (const RCP< const Basic > &arg)
 Canonicalize Cosh:
 
RCP< const Basicsech (const RCP< const Basic > &arg)
 Canonicalize Sech:
 
RCP< const Basictanh (const RCP< const Basic > &arg)
 Canonicalize Tanh:
 
RCP< const Basiccoth (const RCP< const Basic > &arg)
 Canonicalize Coth:
 
RCP< const Basicasinh (const RCP< const Basic > &arg)
 Canonicalize ASinh:
 
RCP< const Basicacsch (const RCP< const Basic > &arg)
 Canonicalize ACsch:
 
RCP< const Basicacosh (const RCP< const Basic > &arg)
 Canonicalize ACosh:
 
RCP< const Basicatanh (const RCP< const Basic > &arg)
 Canonicalize ATanh:
 
RCP< const Basicacoth (const RCP< const Basic > &arg)
 Canonicalize ACoth:
 
RCP< const Basicasech (const RCP< const Basic > &arg)
 Canonicalize ASech:
 
RCP< const Basickronecker_delta (const RCP< const Basic > &i, const RCP< const Basic > &j)
 Canonicalize KroneckerDelta:
 
bool has_dup (const vec_basic &arg)
 
RCP< const Basiceval_levicivita (const vec_basic &arg, int len)
 
RCP< const Basiclevi_civita (const vec_basic &arg)
 Canonicalize LeviCivita:
 
RCP< const Basiczeta (const RCP< const Basic > &s, const RCP< const Basic > &a)
 Create a new Zeta instance:
 
RCP< const Basiczeta (const RCP< const Basic > &s)
 
RCP< const Basicdirichlet_eta (const RCP< const Basic > &s)
 Create a new Dirichlet_eta instance:
 
RCP< const Basicerf (const RCP< const Basic > &arg)
 Canonicalize Erf:
 
RCP< const Basicerfc (const RCP< const Basic > &arg)
 Canonicalize Erfc:
 
RCP< const Basicgamma_positive_int (const RCP< const Basic > &arg)
 
RCP< const Basicgamma_multiple_2 (const RCP< const Basic > &arg)
 
RCP< const Basicgamma (const RCP< const Basic > &arg)
 Canonicalize Gamma:
 
RCP< const Basiclowergamma (const RCP< const Basic > &s, const RCP< const Basic > &x)
 Canonicalize LowerGamma:
 
RCP< const Basicuppergamma (const RCP< const Basic > &s, const RCP< const Basic > &x)
 Canonicalize UpperGamma:
 
RCP< const Basicloggamma (const RCP< const Basic > &arg)
 Canonicalize LogGamma:
 
RCP< const Basicbeta (const RCP< const Basic > &x, const RCP< const Basic > &y)
 Canonicalize Beta:
 
RCP< const Basicpolygamma (const RCP< const Basic > &n, const RCP< const Basic > &x)
 Canonicalize PolyGamma.
 
RCP< const Basicdigamma (const RCP< const Basic > &x)
 
RCP< const Basictrigamma (const RCP< const Basic > &x)
 
RCP< const Basicabs (const RCP< const Basic > &arg)
 Canonicalize Abs:
 
RCP< const Basicmax (const vec_basic &arg)
 Canonicalize Max:
 
RCP< const Basicmin (const vec_basic &arg)
 Canonicalize Min:
 
RCP< const Basicunevaluated_expr (const RCP< const Basic > &arg)
 
RCP< const Basicsqrt (const RCP< const Basic > &arg)
 
RCP< const Basiccbrt (const RCP< const Basic > &arg)
 
RCP< const Inftyinfty (const RCP< const Number > &direction)
 
RCP< const Inftyinfty (int n=1)
 
RCP< const Integerisqrt (const Integer &n)
 Integer Square root.
 
RCP< const Integeriabs (const Integer &n)
 Integer Absolute value.
 
int i_nth_root (const Ptr< RCP< const Integer >> &r, const Integer &a, unsigned long int n)
 Integer nth root.
 
bool perfect_square (const Integer &n)
 Perfect Square.
 
bool perfect_power (const Integer &n)
 Perfect Square.
 
template<typename T >
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer (T i)
 
RCP< const Integerinteger (integer_class i)
 
llvm::Function * get_float_intrinsic (llvm::Type *type, llvm::Intrinsic::ID id, unsigned n, llvm::Module *mod)
 
RCP< const Booleancontains (const RCP< const Basic > &expr, const RCP< const Set > &set)
 
const vec_boolean get_vec_from_set (const set_boolean &s)
 
template<typename caller >
RCP< const Booleanand_or (const set_boolean &s, const bool &op_x_notx)
 
RCP< const Booleanlogical_not (const RCP< const Boolean > &s)
 
RCP< const Booleanlogical_xor (const vec_boolean &s)
 
RCP< const BooleanEq (const RCP< const Basic > &lhs)
 Returns the canonicalized Equality object from a single argument.
 
RCP< const BooleanEq (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized Equality object from the two arguments.
 
RCP< const BooleanNe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized Unequality object from the arguments.
 
RCP< const BooleanLe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized LessThan object from the arguments.
 
RCP< const BooleanGe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Convenience function returning LessThan object.
 
RCP< const BooleanLt (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized StrictLessThan object from the arguments.
 
RCP< const BooleanGt (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Convenience function returning StrictLessThan object.
 
RCP< const Booleanlogical_and (const set_boolean &s)
 
RCP< const Booleanlogical_nand (const set_boolean &s)
 
RCP< const Booleanlogical_or (const set_boolean &s)
 
RCP< const Booleanlogical_nor (const set_boolean &s)
 
RCP< const Booleanlogical_xnor (const vec_boolean &s)
 
RCP< const BooleanAtomboolean (bool b)
 
RCP< const Basicpiecewise (PiecewiseVec &&vec)
 
bool is_a_Relational (const Basic &b)
 
bool is_a_Boolean (const Basic &b)
 
template<class T >
bool is_a (const MatrixBase &b)
 
bool operator== (const SymEngine::MatrixBase &lhs, const SymEngine::MatrixBase &rhs)
 
bool operator!= (const SymEngine::MatrixBase &lhs, const SymEngine::MatrixBase &rhs)
 
void monomial_mul (const vec_int &A, const vec_int &B, vec_int &C)
 Monomial multiplication.
 
integer_class pow (const integer_class &a, unsigned long b)
 
void mp_fdiv_qr (integer_class &q, integer_class &r, const integer_class &a, const integer_class &b)
 
void mp_cdiv_qr (integer_class &q, integer_class &r, const integer_class &a, const integer_class &b)
 
void mp_gcdext (integer_class &gcd, integer_class &s, integer_class &t, const integer_class &a, const integer_class &b)
 
bool mp_invert (integer_class &res, const integer_class &a, const integer_class &m)
 
integer_class fmod (const integer_class &a, const integer_class &mod)
 
void mp_pow_ui (rational_class &res, const rational_class &i, unsigned long n)
 
void mp_powm (integer_class &res, const integer_class &base, const integer_class &exp, const integer_class &m)
 
integer_class step (const unsigned long &n, const integer_class &i, integer_class &x)
 
bool positive_root (integer_class &res, const integer_class &i, const unsigned long n)
 
bool mp_root (integer_class &res, const integer_class &i, const unsigned long n)
 
integer_class mp_sqrt (const integer_class &i)
 
void mp_rootrem (integer_class &a, integer_class &b, const integer_class &i, unsigned long n)
 
void mp_sqrtrem (integer_class &a, integer_class &b, const integer_class &i)
 
int mp_probab_prime_p (const integer_class &i, unsigned retries)
 
void mp_nextprime (integer_class &res, const integer_class &i)
 
unsigned long mp_scan1 (const integer_class &i)
 
two_by_two_matrix fib_matrix (unsigned long n)
 
void mp_fib_ui (integer_class &res, unsigned long n)
 
void mp_fib2_ui (integer_class &a, integer_class &b, unsigned long n)
 
two_by_two_matrix luc_matrix (unsigned long n)
 
void mp_lucnum_ui (integer_class &res, unsigned long n)
 
void mp_lucnum2_ui (integer_class &a, integer_class &b, unsigned long n)
 
void mp_fac_ui (integer_class &res, unsigned long n)
 
void mp_bin_ui (integer_class &res, const integer_class &n, unsigned long r)
 
bool mp_perfect_power_p (const integer_class &i)
 
bool mp_perfect_square_p (const integer_class &i)
 
int mp_legendre (const integer_class &a, const integer_class &n)
 
int unchecked_jacobi (const integer_class &a, const integer_class &n)
 
int mp_jacobi (const integer_class &a, const integer_class &n)
 
int mp_kronecker (const integer_class &a, const integer_class &n)
 
integer_class operator""_z (const char *str)
 Literal for creating multiple precision integers.
 
rational_class operator""_q (const char *str)
 
integer_class mp_abs (const integer_class &i)
 
int mp_sign (const integer_class &i)
 
double mp_get_d (const integer_class &i)
 
void mp_set_d (integer_class &i, double a)
 
void mp_demote (integer_class &i)
 
bool mp_fits_ulong_p (const integer_class &i)
 
bool mp_fits_slong_p (const integer_class &i)
 
unsigned long mp_get_ui (const integer_class &i)
 
long mp_get_si (const integer_class &i)
 
mpz_srcptr get_mpz_t (const integer_class &i)
 
mpz_ptr get_mpz_t (integer_class &i)
 
void mp_pow_ui (integer_class &res, const integer_class &i, unsigned long n)
 
void mp_gcd (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_and (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_fdiv_r (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_fdiv_q (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_cdiv_q (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_tdiv_q (integer_class &res, const integer_class &a, const integer_class &b)
 
void mp_divexact (integer_class &q, const integer_class &a, const integer_class &b)
 
void mp_lcm (integer_class &q, const integer_class &a, const integer_class &b)
 
void mp_tdiv_qr (integer_class &q, integer_class &r, const integer_class &a, const integer_class &b)
 
void mp_addmul (integer_class &r, const integer_class &a, const integer_class &b)
 
const integer_class & get_den (const rational_class &i)
 
const integer_class & get_num (const rational_class &i)
 
integer_class & get_den (rational_class &i)
 
integer_class & get_num (rational_class &i)
 
mpq_srcptr get_mpq_t (const rational_class &i)
 
void canonicalize (rational_class &i)
 
double mp_get_d (const rational_class &i)
 
int mp_sign (const rational_class &i)
 
rational_class mp_abs (const rational_class &i)
 
bool mp_divisible_p (const integer_class &a, const integer_class &b)
 
void mp_urandomm (integer_class &a, gmp_randstate_t &t, const integer_class &b)
 
auto get_mp_t (const integer_class &x) -> decltype(get_mpz_t(x))
 
auto get_mp_t (const rational_class &x) -> decltype(get_mpq_t(x))
 
int mp_cmpabs (const integer_class &a, const integer_class &b)
 
std::ostreamoperator<< (std::ostream &os, const fmpz_wrapper &f)
 
std::ostreamoperator<< (std::ostream &os, const fmpq_wrapper &f)
 
RCP< const Basicmul (const RCP< const Basic > &a, const RCP< const Basic > &b)
 Multiplication.
 
RCP< const Basicmul (const vec_basic &a)
 
RCP< const Basicdiv (const RCP< const Basic > &a, const RCP< const Basic > &b)
 Division.
 
RCP< const Basicneg (const RCP< const Basic > &a)
 Negation.
 
RCP< const Integergcd (const Integer &a, const Integer &b)
 Greatest Common Divisor.
 
void gcd_ext (const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, const Ptr< RCP< const Integer >> &t, const Integer &a, const Integer &b)
 Extended GCD.
 
RCP< const Integerlcm (const Integer &a, const Integer &b)
 Least Common Multiple.
 
int mod_inverse (const Ptr< RCP< const Integer >> &b, const Integer &a, const Integer &m)
 inverse modulo
 
RCP< const Integermod (const Integer &n, const Integer &d)
 modulo round toward zero
 
RCP< const Integerquotient (const Integer &n, const Integer &d)
 
void quotient_mod (const Ptr< RCP< const Integer >> &q, const Ptr< RCP< const Integer >> &r, const Integer &n, const Integer &d)
 
RCP< const Integermod_f (const Integer &n, const Integer &d)
 modulo round toward -inf
 
RCP< const Integerquotient_f (const Integer &n, const Integer &d)
 
void quotient_mod_f (const Ptr< RCP< const Integer >> &q, const Ptr< RCP< const Integer >> &r, const Integer &n, const Integer &d)
 
RCP< const Integerfibonacci (unsigned long n)
 Fibonacci number.
 
void fibonacci2 (const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, unsigned long n)
 Fibonacci n and n-1.
 
RCP< const Integerlucas (unsigned long n)
 Lucas number.
 
void lucas2 (const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, unsigned long n)
 Lucas number n and n-1.
 
RCP< const Integerbinomial (const Integer &n, unsigned long k)
 Binomial Coefficient.
 
RCP< const Integerfactorial (unsigned long n)
 Factorial.
 
bool divides (const Integer &a, const Integer &b)
 
int probab_prime_p (const Integer &a, unsigned reps=25)
 Probabilistic Prime.
 
RCP< const Integernextprime (const Integer &a)
 
int factor_lehman_method (const Ptr< RCP< const Integer >> &f, const Integer &n)
 Factor using lehman's methods.
 
int factor_pollard_pm1_method (const Ptr< RCP< const Integer >> &f, const Integer &n, unsigned B=10, unsigned retries=5)
 Factor using Pollard's p-1 method.
 
int factor_pollard_rho_method (const Ptr< RCP< const Integer >> &f, const Integer &n, unsigned retries=5)
 Factor using Pollard's rho methods.
 
int factor (const Ptr< RCP< const Integer >> &f, const Integer &n, double B1)
 
int factor_trial_division (const Ptr< RCP< const Integer >> &f, const Integer &n)
 
void prime_factors (std::vector< RCP< const Integer >> &primes, const Integer &n)
 Find prime factors of n
 
void prime_factor_multiplicities (map_integer_uint &primes, const Integer &n)
 Find multiplicities of prime factors of n
 
RCP< const Numberbernoulli (unsigned long n)
 
RCP< const Numberharmonic (unsigned long n, long m=1)
 Computes the sum of the inverses of the first perfect mth powers.
 
bool crt (const Ptr< RCP< const Integer >> &R, const std::vector< RCP< const Integer >> &rem, const std::vector< RCP< const Integer >> &mod)
 Chinese remainder function. Return true when a solution exists.
 
bool primitive_root (const Ptr< RCP< const Integer >> &g, const Integer &n)
 Computes a primitive root. Returns false if no primitive root exists.
 
void primitive_root_list (std::vector< RCP< const Integer >> &roots, const Integer &n)
 
RCP< const Integertotient (const RCP< const Integer > &n)
 Euler's totient function.
 
RCP< const Integercarmichael (const RCP< const Integer > &n)
 Carmichael function.
 
bool multiplicative_order (const Ptr< RCP< const Integer >> &o, const RCP< const Integer > &a, const RCP< const Integer > &n)
 Multiplicative order. Return false if order does not exist.
 
int legendre (const Integer &a, const Integer &n)
 Legendre Function.
 
int jacobi (const Integer &a, const Integer &n)
 Jacobi Function.
 
int kronecker (const Integer &a, const Integer &n)
 Kronecker Function.
 
bool _is_nthroot_mod_prime_power (const integer_class &a, const integer_class &n, const integer_class &p, const unsigned k)
 
bool nthroot_mod (const Ptr< RCP< const Integer >> &root, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &m)
 A solution to x**n == a mod m. Return false if none exists.
 
void nthroot_mod_list (std::vector< RCP< const Integer >> &roots, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &m)
 All Solutions to x**n == a mod m. Return false if none exists.
 
bool powermod (const Ptr< RCP< const Integer >> &powm, const RCP< const Integer > &a, const RCP< const Number > &b, const RCP< const Integer > &m)
 
void powermod_list (std::vector< RCP< const Integer >> &pows, const RCP< const Integer > &a, const RCP< const Number > &b, const RCP< const Integer > &m)
 
vec_integer_class quadratic_residues (const Integer &a)
 Finds all Quadratic Residues of a Positive Integer.
 
bool is_quad_residue (const Integer &a, const Integer &p)
 Returns true if 'a' is a quadratic residue of 'p'.
 
bool is_nth_residue (const Integer &a, const Integer &n, const Integer &mod)
 Returns true if 'a' is a nth power residue of 'mod'.
 
int mobius (const Integer &a)
 Mobius Function.
 
long mertens (const unsigned long a)
 
RCP< const Basicprimepi (const RCP< const Basic > &arg)
 
RCP< const Numberaddnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Add self and other
 
RCP< const Numbersubnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Subtract self and other
 
RCP< const Numbermulnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Multiply self and other
 
RCP< const Numberdivnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Divide self and other
 
RCP< const Numberpownum (const RCP< const Number > &self, const RCP< const Number > &other)
 Raise self to power other
 
void iaddnum (const Ptr< RCP< const Number >> &self, const RCP< const Number > &other)
 
void imulnum (const Ptr< RCP< const Number >> &self, const RCP< const Number > &other)
 
void idivnum (const Ptr< RCP< const Number >> &self, const RCP< const Number > &other)
 
bool is_a_Number (const Basic &b)
 
bool is_number_and_zero (const Basic &b)
 
tribool is_zero (const Basic &b)
 
tribool is_positive (const Basic &b)
 
tribool is_nonpositive (const Basic &b)
 
tribool is_negative (const Basic &b)
 
tribool is_nonnegative (const Basic &b)
 
tribool is_real (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_complex (const Basic &b, const Assumptions *assumptions=nullptr)
 
RCP< const Basicparse (const std::string &s, bool convert_xor=true)
 
RCP< const Basicparse_old (const std::string &s, bool convert_xor=true)
 
umap_basic_num _find_gens_poly_pow (const RCP< const Basic > &x, const RCP< const Basic > &base)
 
umap_basic_num _find_gens_poly (const RCP< const Basic > &x)
 
template<typename P >
RCP< const P > from_basic (const RCP< const Basic > &basic, const RCP< const Basic > &gen, bool ex=false)
 
template<typename P >
enable_if_t< is_a_UPoly< P >::value, RCP< const P > > from_basic (const RCP< const Basic > &basic, bool ex=false)
 
template<typename T , typename P >
enable_if_t< std::is_same< T, UExprDict >::value, T > _basic_to_upoly (const RCP< const Basic > &basic, const RCP< const Basic > &gen)
 
template<typename T , typename P >
enable_if_t< std::is_base_of< UIntPolyBase< T, P >, P >::value, T > _basic_to_upoly (const RCP< const Basic > &basic, const RCP< const Basic > &gen)
 
template<typename T , typename P >
enable_if_t< std::is_base_of< URatPolyBase< T, P >, P >::value, T > _basic_to_upoly (const RCP< const Basic > &basic, const RCP< const Basic > &gen)
 
template<typename P >
enable_if_t< std::is_same< MIntPoly, P >::value, typename P::container_type > _basic_to_mpoly (const RCP< const Basic > &basic, const set_basic &gens)
 
template<typename P >
enable_if_t< std::is_same< MExprPoly, P >::value, typename P::container_type > _basic_to_mpoly (const RCP< const Basic > &basic, const set_basic &gens)
 
template<typename P >
RCP< const P > from_basic (const RCP< const Basic > &basic, set_basic &gens, bool ex=false)
 
template<typename P >
enable_if_t< std::is_base_of< MSymEnginePoly< typename P::container_type, P >, P >::value, RCP< const P > > from_basic (const RCP< const Basic > &basic, bool ex=false)
 
template<typename Poly >
void cancel (const RCP< const Basic > &numer, const RCP< const Basic > &denom, const Ptr< RCP< const Poly >> &result_numer, const Ptr< RCP< const Poly >> &result_denom, const Ptr< RCP< const Poly >> &common)
 
unsigned int reconcile (vec_uint &v1, vec_uint &v2, set_basic &s, const set_basic &s1, const set_basic &s2)
 
template<typename Poly , typename Container >
set_basic get_translated_container (Container &x, Container &y, const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > add_mpoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > sub_mpoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > mul_mpoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > neg_mpoly (const Poly &a)
 
template<typename Poly >
RCP< const Poly > pow_mpoly (const Poly &a, unsigned int n)
 
RCP< const UExprPolyuexpr_poly (RCP< const Basic > i, UExprDict &&dict)
 
RCP< const UExprPolyuexpr_poly (RCP< const Basic > i, map_int_Expr &&dict)
 
bool divides_upoly (const UIntPoly &a, const UIntPoly &b, const Ptr< RCP< const UIntPoly >> &out)
 
template<typename T >
unsigned int bit_length (T t)
 
integer_class to_mp_class (const integer_class &i)
 
rational_class to_mp_class (const rational_class &i)
 
template<typename Poly >
RCP< const Poly > add_upoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > neg_upoly (const Poly &a)
 
template<typename Poly >
RCP< const Poly > sub_upoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > mul_upoly (const Poly &a, const Poly &b)
 
template<typename Poly >
RCP< const Poly > quo_upoly (const Poly &a, const Poly &b)
 
bool divides_upoly (const URatPoly &a, const URatPoly &b, const Ptr< RCP< const URatPoly >> &out)
 
template<typename Container , template< typename X, typename Y > class BaseType, typename Poly >
RCP< const Poly > pow_upoly (const USymEnginePoly< Container, BaseType, Poly > &a, unsigned int p)
 
RCP< const Basicpow (const RCP< const Basic > &a, const RCP< const Basic > &b)
 
void multinomial_coefficients (unsigned m, unsigned n, map_vec_uint &r)
 
void multinomial_coefficients_mpz (unsigned m, unsigned n, map_vec_mpz &r)
 
RCP< const Basicexp (const RCP< const Basic > &x)
 Returns the natural exponential function E**x = pow(E, x)
 
RCP< const Basicpow_expand (const RCP< const Pow > &self)
 Expand the power expression.
 
std::string ccode (const Basic &x)
 
std::string jscode (const Basic &x)
 
std::string c89code (const Basic &x)
 
std::string c99code (const Basic &x)
 
std::string latex (const Basic &x)
 
void print_rational_class (const rational_class &r, std::ostringstream &s)
 
std::vector< std::stringinit_latex_printer_names ()
 
std::vector< std::stringinit_mathml_printer_names ()
 
std::string mathml (const Basic &x)
 
std::string ascii_art ()
 
std::string print_double (double d)
 
template<typename T >
char _print_sign (const T &i)
 
template<typename P >
std::string upoly_print (const P &x)
 
std::vector< std::stringinit_str_printer_names ()
 
std::string str (const Basic &x)
 
std::string julia_str (const Basic &x)
 
void get_num_den (const Rational &rat, const Ptr< RCP< const Integer >> &num, const Ptr< RCP< const Integer >> &den)
 returns the num and den of rational rat as RCP<const Integer>
 
RCP< const Numberrational (long n, long d)
 convenience creator from two longs
 
RCP< const RealDoublereal_double (double x)
 
RCP< const Numbernumber (std::complex< double > x)
 
RCP< const Numbernumber (double x)
 
void expr2poly (const RCP< const Basic > &p, umap_basic_num &syms, umap_vec_mpz &P)
 Converts expression p into a polynomial P, with symbols sym
 
void poly_mul (const umap_vec_mpz &A, const umap_vec_mpz &B, umap_vec_mpz &C)
 Multiply two polynomials: C = A*B
 
bool needs_symbolic_constants (const RCP< const Basic > &ex, const RCP< const Symbol > &var)
 
RCP< const SeriesCoeffInterfaceseries (const RCP< const Basic > &ex, const RCP< const Symbol > &var, unsigned int prec)
 
RCP< const SeriesCoeffInterfaceseries_invfunc (const RCP< const Basic > &ex, const RCP< const Symbol > &var, unsigned int prec)
 
RCP< const UnivariateSeriesunivariate_series (RCP< const Symbol > i, unsigned int prec, const UExprDict &s)
 
RCP< const Setmake_set_union (const set_set &in)
 
RCP< const Setset_union (const set_set &in)
 
RCP< const Setset_intersection (const set_set &in)
 
RCP< const Setset_complement_helper (const RCP< const Set > &container, const RCP< const Set > &universe)
 
RCP< const Setset_complement (const RCP< const Set > &universe, const RCP< const Set > &container)
 
RCP< const Setconditionset (const RCP< const Basic > &sym, const RCP< const Boolean > &condition)
 
bool is_a_Set (const Basic &b)
 
RCP< const Realsreals ()
 
RCP< const Rationalsrationals ()
 
RCP< const Integersintegers ()
 
RCP< const EmptySetemptyset ()
 
RCP< const UniversalSetuniversalset ()
 
RCP< const Setfiniteset (const set_basic &container)
 
RCP< const Setinterval (const RCP< const Number > &start, const RCP< const Number > &end, const bool left_open=false, const bool right_open=false)
 
RCP< const Setimageset (const RCP< const Basic > &sym, const RCP< const Basic > &expr, const RCP< const Set > &base)
 
RCP< const Setsolve_poly_linear (const vec_basic &coeffs, const RCP< const Set > &domain)
 
RCP< const Setsolve_poly_quadratic (const vec_basic &coeffs, const RCP< const Set > &domain)
 
RCP< const Setsolve_poly_cubic (const vec_basic &coeffs, const RCP< const Set > &domain)
 
RCP< const Setsolve_poly_quartic (const vec_basic &coeffs, const RCP< const Set > &domain)
 
RCP< const Setsolve_poly_heuristics (const vec_basic &coeffs, const RCP< const Set > &domain)
 
RCP< const Basicget_coeff_basic (const integer_class &i)
 
RCP< const Basicget_coeff_basic (const Expression &i)
 
template<typename Poly >
vec_basic extract_coeffs (const RCP< const Poly > &f)
 
RCP< const Setsolve_poly (const RCP< const Basic > &f, const RCP< const Symbol > &sym, const RCP< const Set > &domain)
 
RCP< const Setsolve_rational (const RCP< const Basic > &f, const RCP< const Symbol > &sym, const RCP< const Set > &domain)
 
bool is_a_LinearArgTrigEquation (const Basic &b, const Symbol &x)
 
RCP< const SetinvertComplex (const RCP< const Basic > &fX, const RCP< const Set > &gY, const RCP< const Symbol > &sym, const RCP< const Dummy > &nD, const RCP< const Set > &domain)
 
RCP< const Setsolve_trig (const RCP< const Basic > &f, const RCP< const Symbol > &sym, const RCP< const Set > &domain)
 
RCP< const Setsolve (const RCP< const Basic > &f, const RCP< const Symbol > &sym, const RCP< const Set > &domain)
 
vec_basic linsolve_helper (const DenseMatrix &A, const DenseMatrix &b)
 
vec_basic linsolve (const DenseMatrix &system, const vec_sym &syms)
 
vec_basic linsolve (const vec_basic &system, const vec_sym &syms)
 
set_basic get_set_from_vec (const vec_sym &syms)
 
std::pair< DenseMatrix, DenseMatrixlinear_eqns_to_matrix (const vec_basic &equations, const vec_sym &syms)
 
void csr_matmat_pass1 (const CSRMatrix &A, const CSRMatrix &B, CSRMatrix &C)
 
void csr_matmat_pass2 (const CSRMatrix &A, const CSRMatrix &B, CSRMatrix &C)
 
void csr_diagonal (const CSRMatrix &A, DenseMatrix &D)
 
void csr_scale_rows (CSRMatrix &A, const DenseMatrix &X)
 
void csr_scale_columns (CSRMatrix &A, const DenseMatrix &X)
 
void csr_binop_csr_canonical (const CSRMatrix &A, const CSRMatrix &B, CSRMatrix &C, RCP< const Basic >(&bin_op)(const RCP< const Basic > &, const RCP< const Basic > &))
 
RCP< const Basicxreplace (const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache)
 Mappings in the subs_dict are applied to the expression tree of x
 
RCP< const Basicsubs (const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache=true)
 
RCP< const Basicmsubs (const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache)
 Subs which treat f(t) and Derivative(f(t), t) as separate variables.
 
RCP< const Basicssubs (const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache)
 SymPy compatible subs.
 
RCP< const Symbolsymbol (const std::string &name)
 inline version to return Symbol
 
RCP< const Dummydummy ()
 inline version to return Dummy
 
RCP< const Dummydummy (const std::string &name)
 
template<typename To , typename From >
To implicit_cast (const From &f)
 
template<typename To , typename From >
To down_cast (From *f)
 
template<typename To , typename From >
To down_cast (From &f)
 
template<typename To , typename From >
To numeric_cast (From f, typename std::enable_if<(std::is_signed< From >::value &&std::is_signed< To >::value)||(std::is_unsigned< From >::value &&std::is_unsigned< To >::value)>::type *=nullptr)
 
template<typename To , typename From >
To numeric_cast (From f, typename std::enable_if<(std::is_signed< From >::value &&std::is_unsigned< To >::value)>::type *=nullptr)
 
template<typename To , typename From >
To numeric_cast (From f, typename std::enable_if<(std::is_unsigned< From >::value &&std::is_signed< To >::value)>::type *=nullptr)
 
template<typename T , typename... Args>
RCP< T > make_rcp (Args &&... args)
 
bool is_polynomial (const Basic &b, const set_basic &variables={})
 Check if expression is a polynomial. More...
 
void preorder_traversal (const Basic &b, Visitor &v)
 
void postorder_traversal (const Basic &b, Visitor &v)
 
void preorder_traversal_stop (const Basic &b, StopVisitor &v)
 
void postorder_traversal_stop (const Basic &b, StopVisitor &v)
 
bool has_symbol (const Basic &b, const Basic &x)
 
RCP< const Basiccoeff (const Basic &b, const Basic &x, const Basic &n)
 
set_basic free_symbols (const MatrixBase &m)
 
set_basic free_symbols (const Basic &b)
 
set_basic function_symbols (const Basic &b)
 
void preorder_traversal_local_stop (const Basic &b, LocalStopVisitor &v)
 
unsigned count_ops (const vec_basic &a)
 
template<typename... Args>
set_basic atoms (const Basic &b)
 

Variables

RCP< const Integerzero = integer(0)
 
RCP< const Integerone = integer(1)
 
RCP< const Integerminus_one = integer(-1)
 
RCP< const NumberI = Complex::from_two_nums(*zero, *one)
 
RCP< const Constantpi = constant("pi")
 
RCP< const ConstantE = constant("E")
 
RCP< const ConstantEulerGamma = constant("EulerGamma")
 
RCP< const ConstantCatalan = constant("Catalan")
 
RCP< const ConstantGoldenRatio = constant("GoldenRatio")
 
RCP< const InftyInf = Infty::from_int(1)
 
RCP< const InftyNegInf = Infty::from_int(-1)
 
RCP< const InftyComplexInf = Infty::from_int(0)
 
RCP< const NaNNan = make_rcp<NaN>()
 
RCP< const Basici2 = integer(2)
 
RCP< const Basici3 = integer(3)
 
RCP< const Basici5 = integer(5)
 
RCP< const Basicim2 = integer(-2)
 
RCP< const Basicim3 = integer(-3)
 
RCP< const Basicim5 = integer(-5)
 
RCP< const Basicsq3 = sqrt_(i3)
 
RCP< const Basicsq2 = sqrt_(i2)
 
RCP< const Basicsq5 = sqrt_(i5)
 
RCP< const BasicC0 = div(sub(sq3, one), mul(i2, sq2))
 
RCP< const BasicC1 = div(one, i2)
 
RCP< const BasicC2 = div(sq2, i2)
 
RCP< const BasicC3 = div(sq3, i2)
 
RCP< const BasicC4 = div(add(sq3, one), mul(i2, sq2))
 
RCP< const BasicC5 = div(sqrt_(sub(i5, sqrt_(i5))), integer(8))
 
RCP< const BasicC6 = div(sub(sqrt_(i5), one), integer(4))
 
RCP< const BasicmC0 = mul(minus_one, C0)
 
RCP< const BasicmC1 = mul(minus_one, C1)
 
RCP< const BasicmC2 = mul(minus_one, C2)
 
RCP< const BasicmC3 = mul(minus_one, C3)
 
RCP< const BasicmC4 = mul(minus_one, C4)
 
RCP< const BasicmC5 = mul(minus_one, C5)
 
RCP< const BasicmC6 = mul(minus_one, C6)
 
RCP< const Basicsin_table []
 
umap_basic_basic inverse_cst
 
umap_basic_basic inverse_tct
 
static const std::vector< fntable_eval_double = init_eval_double()
 
RCP< const BooleanAtomboolTrue = make_rcp<BooleanAtom>(true)
 
RCP< const BooleanAtomboolFalse = make_rcp<BooleanAtom>(false)
 

Detailed Description

Main namespace for SymEngine package.

Enumeration Type Documentation

◆ TypeID

Enumerator
TypeID_Count 

The 'TypeID_Count' returns the number of elements in 'TypeID'. For this to work, do not assign numbers to the elements above (or if you do, you must assign the correct count below).

Definition at line 43 of file basic.h.

43  {
44 #define SYMENGINE_INCLUDE_ALL
45 #define SYMENGINE_ENUM(type, Class) type,
46 #include "symengine/type_codes.inc"
47 #undef SYMENGINE_ENUM
48 #undef SYMENGINE_INCLUDE_ALL
53 };
@ TypeID_Count
Definition: basic.h:52

Function Documentation

◆ add() [1/2]

RCP< const Basic > add ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
)

Adds two objects (safely).

This implementation is slower than the methods of Add, however it is conceptually simpler and also safer, as it is more general and can perform canonicalization.

Note that:

x + y will return an Add. x + x will return Mul (2*x).

Parameters
ais a Basic object.
bis a Basic object.
Returns
a+b in its most aproriate form.

Definition at line 427 of file add.cpp.

428 {
430  RCP<const Number> coef;
431  RCP<const Basic> t;
432  if (is_a<Add>(*a) and is_a<Add>(*b)) {
433  coef = (down_cast<const Add &>(*a)).get_coef();
434  d = (down_cast<const Add &>(*a)).get_dict();
435  for (const auto &p : (down_cast<const Add &>(*b)).get_dict())
436  Add::dict_add_term(d, p.second, p.first);
437  iaddnum(outArg(coef), down_cast<const Add &>(*b).get_coef());
438  } else if (is_a<Add>(*a)) {
439  coef = (down_cast<const Add &>(*a)).get_coef();
440  d = (down_cast<const Add &>(*a)).get_dict();
441  if (is_a_Number(*b)) {
442  if (not down_cast<const Number &>(*b).is_zero()) {
443  iaddnum(outArg(coef), rcp_static_cast<const Number>(b));
444  }
445  } else {
446  RCP<const Number> coef2;
447  Add::as_coef_term(b, outArg(coef2), outArg(t));
448  Add::dict_add_term(d, coef2, t);
449  }
450  } else if (is_a<Add>(*b)) {
451  coef = (down_cast<const Add &>(*b)).get_coef();
452  d = (down_cast<const Add &>(*b)).get_dict();
453  if (is_a_Number(*a)) {
454  if (not down_cast<const Number &>(*a).is_zero()) {
455  iaddnum(outArg(coef), rcp_static_cast<const Number>(a));
456  }
457  } else {
458  RCP<const Number> coef2;
459  Add::as_coef_term(a, outArg(coef2), outArg(t));
460  Add::dict_add_term(d, coef2, t);
461  }
462  } else {
463  Add::as_coef_term(a, outArg(coef), outArg(t));
464  Add::dict_add_term(d, coef, t);
465  Add::as_coef_term(b, outArg(coef), outArg(t));
466  Add::dict_add_term(d, coef, t);
467  auto it = d.find(one);
468  if (it == d.end()) {
469  coef = zero;
470  } else {
471  coef = it->second;
472  d.erase(it);
473  }
474  return Add::from_dict(coef, std::move(d));
475  }
476  return Add::from_dict(coef, std::move(d));
477 }
T end(T... args)
T erase(T... args)
T find(T... args)
T move(T... args)
bool is_a_Number(const Basic &b)
Definition: number.h:130

◆ add() [2/2]

RCP< const Basic > add ( const vec_basic a)

Sums the elements of a vector.

This should be faster for n elements compared to performing n-1 additions.

Parameters
ais a vector.
Returns
sum of elements of the input vector a.

Definition at line 483 of file add.cpp.

484 {
486  RCP<const Number> coef = zero;
487  for (const auto &i : a) {
488  Add::coef_dict_add_term(outArg(coef), d, one, i);
489  }
490  return Add::from_dict(coef, std::move(d));
491 }

◆ bernoulli()

RCP< const Number > SymEngine::bernoulli ( unsigned long  n)

Computes the Bernoulli number Bn as an exact fraction, for an isolated integer n

Definition at line 606 of file ntheory.cpp.

607 {
608 #ifdef HAVE_SYMENGINE_ARB
609  fmpq_t res;
610  fmpq_init(res);
611  bernoulli_fmpq_ui(res, n);
612  mpq_t a;
613  mpq_init(a);
614  fmpq_get_mpq(a, res);
615  rational_class b(a);
616  fmpq_clear(res);
617  mpq_clear(a);
618  return Rational::from_mpq(std::move(b));
619 #else
620  // TODO: implement a faster algorithm
622  for (unsigned m = 0; m <= n; ++m) {
623  v[m] = rational_class(1u, m + 1);
624 
625  for (unsigned j = m; j >= 1; --j) {
626  v[j - 1] = j * (v[j - 1] - v[j]);
627  }
628  }
629  return Rational::from_mpq(v[0]);
630 #endif
631 }

◆ cbrt()

RCP< const Basic > SymEngine::cbrt ( const RCP< const Basic > &  x)
inline
Returns
cbrt of the arg
cube root of x

Definition at line 66 of file pow.h.

67 {
68  return pow(x, div(one, integer(3)));
69 }
T div(T... args)
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
Definition: integer.h:202
T pow(T... args)

◆ conditionset()

RCP< const Set > SymEngine::conditionset ( const RCP< const Basic > &  sym,
const RCP< const Boolean > &  condition 
)
Returns
RCP<const Set>

Definition at line 1387 of file sets.cpp.

1389 {
1390  if (eq(*condition, *boolean(false))) {
1391  return emptyset();
1392  } else if (eq(*condition, *boolean(true))) {
1393  return universalset();
1394  }
1395  if (is_a<And>(*condition)) {
1396  auto cont = down_cast<const And &>(*condition).get_container();
1397  set_boolean newcont;
1398  set_basic present, others;
1399  for (auto it = cont.begin(); it != cont.end(); it++) {
1400  if (is_a<Contains>(**it)
1401  and eq(*down_cast<const Contains &>(**it).get_expr(), *sym)
1402  and is_a<FiniteSet>(
1403  *down_cast<const Contains &>(**it).get_set())) {
1404  auto fset = down_cast<const Contains &>(**it).get_set();
1405  auto fcont
1406  = down_cast<const FiniteSet &>(*fset).get_container();
1407  // use the result of simplification done in `logical_and()`
1408  for (const auto &elem : fcont) {
1409  if (not(is_a_Number(*elem) or is_a<Constant>(*elem))) {
1410  others.insert(elem);
1411  } else {
1412  // logical_and() doesn't guarantee that if element of a
1413  // finiteset is a number, then it satisfies other
1414  // conditions
1415  // it only assures that there doesn't exist any such
1416  // element of finiteset that surely fails in other
1417  // conditions.
1418  auto restCont = cont;
1419  restCont.erase(*it);
1420  auto restCond = logical_and(restCont);
1421  map_basic_basic d;
1422  d[sym] = elem;
1423  auto contain = restCond->subs(d);
1424  if (eq(*contain, *boolean(true))) {
1425  present.insert(elem);
1426  } else if (not eq(*contain, *boolean(false))) {
1427  others.insert(elem);
1428  } else {
1429  throw SymEngineException("element should have "
1430  "been removed within "
1431  "logical_and()");
1432  }
1433  }
1434  }
1435  } else {
1436  newcont.insert(*it);
1437  }
1438  }
1439  if (not present.empty()) {
1440  newcont.insert(finiteset(others)->contains(sym));
1441  return SymEngine::set_union(
1442  {finiteset(present), conditionset(sym, logical_and(newcont))});
1443  }
1444  }
1445  if (is_a<Contains>(*condition)) {
1446  return down_cast<const Contains &>(*condition).get_set();
1447  }
1448  return make_rcp<const ConditionSet>(sym, condition);
1449 }
T insert(T... args)
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
RCP< const EmptySet > emptyset()
Definition: sets.h:455
RCP< const UniversalSet > universalset()
Definition: sets.h:461
RCP< const Set > conditionset(const RCP< const Basic > &sym, const RCP< const Boolean > &condition)
Definition: sets.cpp:1387
RCP< const Set > finiteset(const set_basic &container)
Definition: sets.h:467

◆ could_extract_minus()

bool SymEngine::could_extract_minus ( const Basic arg)
Returns
true if arg contains a negative sign.

Definition at line 280 of file functions.cpp.

281 {
282  if (is_a_Number(arg)) {
283  if (down_cast<const Number &>(arg).is_negative()) {
284  return true;
285  } else if (is_a_Complex(arg)) {
286  const ComplexBase &c = down_cast<const ComplexBase &>(arg);
287  RCP<const Number> real_part = c.real_part();
288  return (real_part->is_negative())
289  or (eq(*real_part, *zero)
290  and c.imaginary_part()->is_negative());
291  } else {
292  return false;
293  }
294  } else if (is_a<Mul>(arg)) {
295  const Mul &s = down_cast<const Mul &>(arg);
296  return could_extract_minus(*s.get_coef());
297  } else if (is_a<Add>(arg)) {
298  const Add &s = down_cast<const Add &>(arg);
299  if (s.get_coef()->is_zero()) {
300  map_basic_num d(s.get_dict().begin(), s.get_dict().end());
301  return could_extract_minus(*d.begin()->second);
302  } else {
303  return could_extract_minus(*s.get_coef());
304  }
305  } else {
306  return false;
307  }
308 }
bool could_extract_minus(const Basic &arg)
Definition: functions.cpp:280
bool is_a_Complex(const Basic &b)
Definition: complex.h:24

◆ divides()

bool SymEngine::divides ( const Integer a,
const Integer b 
)
Returns
true if b divides a

Definition at line 158 of file ntheory.cpp.

159 {
160  return mp_divisible_p(a.as_integer_class(), b.as_integer_class()) != 0;
161 }

◆ emptyset()

RCP<const EmptySet> SymEngine::emptyset ( )
inline
Returns
RCP<const EmptySet>

Definition at line 455 of file sets.h.

456 {
457  return EmptySet::getInstance();
458 }

◆ eq()

bool SymEngine::eq ( const Basic a,
const Basic b 
)
inline

Checks equality for a and b

Returns
true if a equal b

Definition at line 21 of file basic-inl.h.

22 {
23  if (&a == &b) {
24  return true;
25  }
26  return a.__eq__(b);
27 }

◆ factor()

int SymEngine::factor ( const Ptr< RCP< const Integer >> &  f,
const Integer n,
double  B1 = 1.0 
)

Factorization

Parameters
B1is only used when n is factored using gmp-ecm

Definition at line 367 of file ntheory.cpp.

368 {
369  int ret_val = 0;
370  integer_class _n, _f;
371 
372  _n = n.as_integer_class();
373 
374 #ifdef HAVE_SYMENGINE_ECM
375  if (mp_perfect_power_p(_n)) {
376 
377  unsigned long int i = 1;
378  integer_class m, rem;
379  rem = 1; // Any non zero number
380  m = 2; // set `m` to 2**i, i = 1 at the begining
381 
382  // calculate log2n, this can be improved
383  for (; m < _n; ++i)
384  m = m * 2;
385 
386  // eventually `rem` = 0 zero as `n` is a perfect power. `f_t` will
387  // be set to a factor of `n` when that happens
388  while (i > 1 and rem != 0) {
389  mp_rootrem(_f, rem, _n, i);
390  --i;
391  }
392 
393  ret_val = 1;
394  } else {
395 
396  if (mp_probab_prime_p(_n, 25) > 0) { // most probably, n is a prime
397  ret_val = 0;
398  _f = _n;
399  } else {
400 
401  for (int i = 0; i < 10 and not ret_val; ++i)
402  ret_val = ecm_factor(get_mpz_t(_f), get_mpz_t(_n), B1, nullptr);
403  mp_demote(_f);
404  if (not ret_val)
405  throw SymEngineException(
406  "ECM failed to factor the given number");
407  }
408  }
409 #else
410  // B1 is discarded if gmp-ecm is not installed
411  ret_val = _factor_trial_division_sieve(_f, _n);
412 #endif // HAVE_SYMENGINE_ECM
413  *f = integer(std::move(_f));
414 
415  return ret_val;
416 }

◆ factor_trial_division()

int SymEngine::factor_trial_division ( const Ptr< RCP< const Integer >> &  f,
const Integer n 
)

Factor using trial division.

Returns
1 if a non-trivial factor is found, otherwise 0.

Definition at line 418 of file ntheory.cpp.

419 {
420  int ret_val;
421  integer_class factor;
422  ret_val = _factor_trial_division_sieve(factor, n.as_integer_class());
423  if (ret_val == 1)
424  *f = integer(std::move(factor));
425  return ret_val;
426 }
int factor(const Ptr< RCP< const Integer >> &f, const Integer &n, double B1)
Definition: ntheory.cpp:367

◆ finiteset()

RCP<const Set> SymEngine::finiteset ( const set_basic container)
inline
Returns
RCP<const Set>

Definition at line 467 of file sets.h.

468 {
469  if (FiniteSet::is_canonical(container)) {
470  return make_rcp<const FiniteSet>(container);
471  }
472  return emptyset();
473 }

◆ get_pi_shift()

bool SymEngine::get_pi_shift ( const RCP< const Basic > &  arg,
const Ptr< RCP< const Number >> &  n,
const Ptr< RCP< const Basic >> &  m 
)
Returns
true if arg is of form m + n*pi where n is a rational

Definition at line 160 of file functions.cpp.

162 {
163  if (is_a<Add>(*arg)) {
164  const Add &s = down_cast<const Add &>(*arg);
165  RCP<const Basic> coef = s.get_coef();
166  auto size = s.get_dict().size();
167  if (size > 1) {
168  // arg should be of form `x + n*pi`
169  // `n` is an integer
170  // `x` is an `Expression`
171  bool check_pi = false;
172  RCP<const Basic> temp;
173  *x = coef;
174  for (const auto &p : s.get_dict()) {
175  if (eq(*p.first, *pi) and (is_a<Integer>(*p.second)
176  or is_a<Rational>(*p.second))) {
177  check_pi = true;
178  *n = p.second;
179  } else {
180  *x = add(mul(p.first, p.second), *x);
181  }
182  }
183  if (check_pi)
184  return true;
185  else // No term with `pi` found
186  return false;
187  } else if (size == 1) {
188  // arg should be of form `a + n*pi`
189  // where `a` is a `Number`.
190  auto p = s.get_dict().begin();
191  if (eq(*p->first, *pi)
192  and (is_a<Integer>(*p->second) or is_a<Rational>(*p->second))) {
193  *n = p->second;
194  *x = coef;
195  return true;
196  } else {
197  return false;
198  }
199  } else { // Should never reach here though!
200  // Dict of size < 1
201  return false;
202  }
203  } else if (is_a<Mul>(*arg)) {
204  // `arg` is of the form `k*pi/12`
205  const Mul &s = down_cast<const Mul &>(*arg);
206  auto p = s.get_dict().begin();
207  // dict should contain symbol `pi` only
208  if (s.get_dict().size() == 1 and eq(*p->first, *pi)
209  and eq(*p->second, *one) and (is_a<Integer>(*s.get_coef())
210  or is_a<Rational>(*s.get_coef()))) {
211  *n = s.get_coef();
212  *x = zero;
213  return true;
214  } else {
215  return false;
216  }
217  } else if (eq(*arg, *pi)) {
218  *n = one;
219  *x = zero;
220  return true;
221  } else if (eq(*arg, *zero)) {
222  *n = zero;
223  *x = zero;
224  return true;
225  } else {
226  return false;
227  }
228 }
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:427
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:347

◆ hash_combine()

template<class T >
void SymEngine::hash_combine ( hash_t &  seed,
const T &  v 
)
inline

Standard hash_combine() function. Example of usage:

hash_t seed1 = 0;
hash_combine<std::string>(seed1, "x");
hash_combine<std::string>(seed1, "y");

You can use it with any SymEngine class:

RCP<const Symbol> x = symbol("x");
RCP<const Symbol> y = symbol("y");
hash_t seed2 = 0;
hash_combine<Basic>(seed2, *x);
hash_combine<Basic>(seed2, *y);

Definition at line 137 of file basic-inl.h.

138 {
139  hash_combine_impl(seed, v);
140 }
void hash_combine_impl(hash_t &seed, const T &v, typename std::enable_if< std::is_base_of< Basic, T >::value >::type *=nullptr)
Templatised version to combine hash.
Definition: basic-inl.h:103

◆ insert()

template<typename T1 , typename T2 , typename T3 >
void SymEngine::insert ( T1 &  m,
const T2 &  first,
const T3 &  second 
)
inline

insert(m, first, second) is equivalent to m[first] = second, just faster, because no default constructor is called on the second type.

Definition at line 83 of file dict.h.

84 {
85  m.insert(std::pair<T2, T3>(first, second));
86 }

◆ integer() [1/2]

RCP<const Integer> SymEngine::integer ( integer_class  i)
inline
Returns
RCP<const Integer> from integer_class

Definition at line 208 of file integer.h.

209 {
210  return make_rcp<const Integer>(std::move(i));
211 }

◆ integer() [2/2]

template<typename T >
std::enable_if<std::is_integral<T>::value, RCP<const Integer> >::type SymEngine::integer ( i)
inline
Returns
RCP<const Integer> from integral values

Definition at line 202 of file integer.h.

203 {
204  return make_rcp<const Integer>(integer_class(i));
205 }

◆ integers()

RCP<const Integers> SymEngine::integers ( )
inline
Returns
RCP<const Reals>

Definition at line 449 of file sets.h.

450 {
451  return Integers::getInstance();
452 }

◆ interval()

RCP<const Set> SymEngine::interval ( const RCP< const Number > &  start,
const RCP< const Number > &  end,
const bool  left_open = false,
const bool  right_open = false 
)
inline
Returns
RCP<const Set>

Definition at line 476 of file sets.h.

480 {
481  if (Interval::is_canonical(start, end, left_open, right_open))
482  return make_rcp<const Interval>(start, end, left_open, right_open);
483  if (eq(*start, *end) and not(left_open or right_open))
484  return finiteset({start});
485  return emptyset();
486 }

◆ inverse_lookup()

bool SymEngine::inverse_lookup ( umap_basic_basic d,
const RCP< const Basic > &  t,
const Ptr< RCP< const Basic >> &  index 
)

returns true if the given argument t is found in the lookup table d. It also returns the value in index

Definition at line 435 of file functions.cpp.

437 {
438  auto it = d.find(t);
439  if (it == d.end()) {
440  // Not found in lookup
441  return false;
442  } else {
443  *index = (it->second);
444  return true;
445  }
446 }

◆ is_a()

template<class T >
bool SymEngine::is_a ( const Basic b)
inline

Templatised version to check is_a type.

Returns true if b is exactly of type T. Example: is_a<Symbol>(b) : true if "b" is of type Symbol

Definition at line 36 of file basic-inl.h.

37 {
38  return T::type_code_id == b.get_type_code();
39 }

◆ is_a_Complex()

bool SymEngine::is_a_Complex ( const Basic b)
inline
Returns
true if 'b' is any of the subclasses of ComplexBase

Definition at line 24 of file complex.h.

25 {
26  return (b.get_type_code() == SYMENGINE_COMPLEX
27  || b.get_type_code() == SYMENGINE_COMPLEX_MPC
28  || b.get_type_code() == SYMENGINE_COMPLEX_DOUBLE);
29 }

◆ is_a_Number()

bool SymEngine::is_a_Number ( const Basic b)
inline
Returns
true if 'b' is a Number or any of its subclasses

Definition at line 130 of file number.h.

131 {
132  // `NumberWraper` is the last subclass of Number in TypeID
133  // An enum should be before `SYMENIGNE_NUMBER_WRAPPER` iff it is a
134  // subclass of Number
135  return b.get_type_code() <= SYMENGINE_NUMBER_WRAPPER;
136 }

◆ is_a_sub()

template<class T >
bool SymEngine::is_a_sub ( const Basic b)
inline

Returns true if b is of type T or any of its subclasses. Example:

 is_a_sub<Symbol>(b)  // true if `b` is of type `Symbol` or any Symbol's

subclass

Definition at line 42 of file basic-inl.h.

43 {
44  return dynamic_cast<const T *>(&b) != nullptr;
45 }

◆ is_number_and_zero()

bool SymEngine::is_number_and_zero ( const Basic b)
inline
Returns
true if 'b' is a Number and is zero

Definition at line 139 of file number.h.

140 {
141  return is_a_Number(b) and down_cast<const Number &>(b).is_zero();
142 }

◆ is_polynomial()

bool SymEngine::is_polynomial ( const Basic b,
const set_basic variables = {} 
)

Check if expression is a polynomial.

Parameters
bBasic
variablesSet of symbols for variables in polynomial
Returns
True if b is a polynomial in variables and false otherwise

Check if b is a polynomial in variables. If no variables are specified all free symbols in b are considered to be variables. All symbols that are not variables will be considered to be constants.

Definition at line 423 of file test_visitors.cpp.

424 {
425  PolynomialVisitor visitor(variables);
426  return visitor.apply(b);
427 }

◆ log()

RCP< const Basic > SymEngine::log ( const RCP< const Basic > &  arg,
const RCP< const Basic > &  b 
)
Returns
Log from argument arg wrt base b

Definition at line 1772 of file functions.cpp.

1773 {
1774  return div(log(arg), log(base));
1775 }
T log(T... args)

◆ neq()

bool SymEngine::neq ( const Basic a,
const Basic b 
)
inline

Checks inequality for a and b

Returns
true if a not equal b

Definition at line 29 of file basic-inl.h.

30 {
31  return not(a.__eq__(b));
32 }

◆ nextprime()

RCP< const Integer > SymEngine::nextprime ( const Integer a)
Returns
next prime after a

Definition at line 169 of file ntheory.cpp.

170 {
171  integer_class c;
172  mp_nextprime(c, a.as_integer_class());
173  return integer(std::move(c));
174 }

◆ operator<<()

std::ostream & SymEngine::operator<< ( std::ostream out,
const SymEngine::Basic p 
)
inline

<< Operator

This << overloaded function simply calls p.__str__, so it allows any Basic type to be printed.

This prints using: std::cout << *x;

Definition at line 95 of file basic-inl.h.

96 {
97  out << p.__str__();
98  return out;
99 }
std::string __str__() const
Definition: basic.cpp:22

◆ pow()

RCP< const Basic > SymEngine::pow ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
)
Returns
Pow from a and b

Definition at line 91 of file pow.cpp.

92 {
93  if (is_number_and_zero(*b)) {
94  // addnum is used for converting to the type of `b`.
95  return addnum(one, rcp_static_cast<const Number>(b));
96  }
97  if (eq(*b, *one))
98  return a;
99 
100  if (eq(*a, *zero)) {
101  if (is_a_Number(*b)
102  and rcp_static_cast<const Number>(b)->is_positive()) {
103  return zero;
104  } else if (is_a_Number(*b)
105  and rcp_static_cast<const Number>(b)->is_negative()) {
106  return ComplexInf;
107  } else {
108  return make_rcp<const Pow>(a, b);
109  }
110  }
111 
112  if (eq(*a, *one) and not is_a_Number(*b))
113  return one;
114  if (eq(*a, *minus_one)) {
115  if (is_a<Integer>(*b)) {
116  return is_a<Integer>(*div(b, integer(2))) ? one : minus_one;
117  } else if (is_a<Rational>(*b) and eq(*b, *rational(1, 2))) {
118  return I;
119  }
120  }
121 
122  if (is_a_Number(*b)) {
123  if (is_a_Number(*a)) {
124  if (is_a<Integer>(*b)) {
125  return down_cast<const Number &>(*a).pow(
126  *rcp_static_cast<const Number>(b));
127  } else if (is_a<Rational>(*b)) {
128  if (is_a<Rational>(*a)) {
129  return down_cast<const Rational &>(*a).powrat(
130  down_cast<const Rational &>(*b));
131  } else if (is_a<Integer>(*a)) {
132  return down_cast<const Rational &>(*b).rpowrat(
133  down_cast<const Integer &>(*a));
134  } else if (is_a<Complex>(*a)) {
135  return make_rcp<const Pow>(a, b);
136  } else {
137  return down_cast<const Number &>(*a).pow(
138  *rcp_static_cast<const Number>(b));
139  }
140  } else if (is_a<Complex>(*b)
141  and down_cast<const Number &>(*a).is_exact()) {
142  return make_rcp<const Pow>(a, b);
143  } else {
144  return down_cast<const Number &>(*a).pow(
145  *rcp_static_cast<const Number>(b));
146  }
147  } else if (eq(*a, *E)) {
148  RCP<const Number> p = rcp_static_cast<const Number>(b);
149  if (not p->is_exact()) {
150  // Evaluate E**0.2, but not E**2
151  return p->get_eval().exp(*p);
152  }
153  } else if (is_a<Mul>(*a)) {
154  // Expand (x*y)**b = x**b*y**b
155  map_basic_basic d;
156  RCP<const Number> coef = one;
157  down_cast<const Mul &>(*a).power_num(
158  outArg(coef), d, rcp_static_cast<const Number>(b));
159  return Mul::from_dict(coef, std::move(d));
160  }
161  }
162  if (is_a<Pow>(*a) and is_a<Integer>(*b)) {
163  // Convert (x**y)**b = x**(b*y), where 'b' is an integer. This holds for
164  // any complex 'x', 'y' and integer 'b'.
165  RCP<const Pow> A = rcp_static_cast<const Pow>(a);
166  return pow(A->get_base(), mul(A->get_exp(), b));
167  }
168  if (is_a<Pow>(*a)
169  and eq(*down_cast<const Pow &>(*a).get_exp(), *minus_one)) {
170  // Convert (x**-1)**b = x**(-b)
171  RCP<const Pow> A = rcp_static_cast<const Pow>(a);
172  return pow(A->get_base(), neg(b));
173  }
174  return make_rcp<const Pow>(a, b);
175 }
bool is_number_and_zero(const Basic &b)
Definition: number.h:139
RCP< const Number > rational(long n, long d)
convenience creator from two longs
Definition: rational.h:328
RCP< const Number > addnum(const RCP< const Number > &self, const RCP< const Number > &other)
Add self and other
Definition: number.h:81
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:438

◆ powermod()

bool SymEngine::powermod ( const Ptr< RCP< const Integer >> &  powm,
const RCP< const Integer > &  a,
const RCP< const Number > &  b,
const RCP< const Integer > &  m 
)

A solution to x**s == a**r mod m where b = r / s. Return false if none exists.

Definition at line 1544 of file ntheory.cpp.

1546 {
1547  if (is_a<Integer>(*b)) {
1548  integer_class t = down_cast<const Integer &>(*b).as_integer_class();
1549  if (b->is_negative())
1550  t *= -1;
1551  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1552  if (b->is_negative()) {
1553  bool ret_val = mp_invert(t, t, m->as_integer_class());
1554  if (not ret_val)
1555  return false;
1556  }
1557  *powm = integer(std::move(t));
1558  return true;
1559  } else if (is_a<Rational>(*b)) {
1560  RCP<const Integer> num, den, r;
1561  get_num_den(down_cast<const Rational &>(*b), outArg(num), outArg(den));
1562  if (den->is_negative()) {
1563  den = den->mulint(*minus_one);
1564  num = num->mulint(*minus_one);
1565  }
1566  integer_class t = mp_abs(num->as_integer_class());
1567  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1568  if (num->is_negative()) {
1569  bool ret_val = mp_invert(t, t, m->as_integer_class());
1570  if (not ret_val)
1571  return false;
1572  }
1573  r = integer(std::move(t));
1574  return nthroot_mod(powm, r, den, m);
1575  }
1576  return false;
1577 }
void get_num_den(const Rational &rat, const Ptr< RCP< const Integer >> &num, const Ptr< RCP< const Integer >> &den)
returns the num and den of rational rat as RCP<const Integer>
Definition: rational.cpp:114
bool nthroot_mod(const Ptr< RCP< const Integer >> &root, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &mod)
A solution to x**n == a mod m. Return false if none exists.
Definition: ntheory.cpp:1482

◆ powermod_list()

void SymEngine::powermod_list ( std::vector< RCP< const Integer >> &  pows,
const RCP< const Integer > &  a,
const RCP< const Number > &  b,
const RCP< const Integer > &  m 
)

All solutions to x**s == a**r mod m where b = r / s. Return false if none exists.

Definition at line 1579 of file ntheory.cpp.

1582 {
1583  if (is_a<Integer>(*b)) {
1584  integer_class t
1585  = mp_abs(down_cast<const Integer &>(*b).as_integer_class());
1586  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1587  if (b->is_negative()) {
1588  bool ret_val = mp_invert(t, t, m->as_integer_class());
1589  if (not ret_val)
1590  return;
1591  }
1592  pows.push_back(integer(std::move(t)));
1593  } else if (is_a<Rational>(*b)) {
1594  RCP<const Integer> num, den, r;
1595  get_num_den(down_cast<const Rational &>(*b), outArg(num), outArg(den));
1596  if (den->is_negative()) {
1597  den = den->mulint(*integer(-1));
1598  num = num->mulint(*integer(-1));
1599  }
1600  integer_class t = num->as_integer_class();
1601  if (num->is_negative())
1602  t *= -1;
1603  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1604  if (num->is_negative()) {
1605  bool ret_val = mp_invert(t, t, m->as_integer_class());
1606  if (not ret_val)
1607  return;
1608  }
1609  r = integer(t);
1610  nthroot_mod_list(pows, r, den, m);
1611  }
1612 }
void nthroot_mod_list(std::vector< RCP< const Integer >> &roots, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &m)
All Solutions to x**n == a mod m. Return false if none exists.
Definition: ntheory.cpp:1512
T push_back(T... args)

◆ primitive_root_list()

void SymEngine::primitive_root_list ( std::vector< RCP< const Integer >> &  roots,
const Integer n 
)

Computes all primitive roots less than n. Returns false if no primitive root exists.

Definition at line 875 of file ntheory.cpp.

877 {
878  integer_class _n = n.as_integer_class();
879  if (_n < 0)
880  _n = -_n;
881  if (_n <= 1)
882  return;
883  if (_n < 5) {
884  roots.push_back(integer(_n - 1));
885  return;
886  }
887  bool even = false;
888  if (_n % 2 == 0) {
889  if (_n % 4 == 0) {
890  return; // If n%4 == 0 and n > 4, then no primitive roots.
891  }
892  _n /= 2;
893  even = true;
894  }
895  integer_class p, e;
896  if (not _prime_power(p, e, _n))
897  return;
898  _primitive_root_list(roots, p, e, even);
899  std::sort(roots.begin(), roots.end(), SymEngine::RCPIntegerKeyLess());
900  return;
901 }
T begin(T... args)
T sort(T... args)
less operator (<) for Integers
Definition: integer.h:190

◆ quotient()

RCP< const Integer > SymEngine::quotient ( const Integer n,
const Integer d 
)
Returns
quotient round toward zero when n is divided by d

Definition at line 68 of file ntheory.cpp.

69 {
70  return integer(n.as_integer_class() / d.as_integer_class());
71 }

◆ quotient_f()

RCP< const Integer > SymEngine::quotient_f ( const Integer n,
const Integer d 
)
Returns
quotient round toward -inf when n is divided by d

Definition at line 90 of file ntheory.cpp.

91 {
92  integer_class q;
93  mp_fdiv_q(q, n.as_integer_class(), d.as_integer_class());
94  return integer(std::move(q));
95 }

◆ quotient_mod()

void SymEngine::quotient_mod ( const Ptr< RCP< const Integer >> &  q,
const Ptr< RCP< const Integer >> &  r,
const Integer a,
const Integer b 
)
Returns
modulo and quotient round toward zero

Definition at line 73 of file ntheory.cpp.

76 {
77  integer_class _q, _r;
78  mp_tdiv_qr(_q, _r, n.as_integer_class(), d.as_integer_class());
79  *q = integer(std::move(_q));
80  *r = integer(std::move(_r));
81 }

◆ quotient_mod_f()

void SymEngine::quotient_mod_f ( const Ptr< RCP< const Integer >> &  q,
const Ptr< RCP< const Integer >> &  r,
const Integer a,
const Integer b 
)
Returns
modulo and quotient round toward -inf

Definition at line 97 of file ntheory.cpp.

100 {
101  integer_class _q, _r;
102  mp_fdiv_qr(_q, _r, n.as_integer_class(), d.as_integer_class());
103  *q = integer(std::move(_q));
104  *r = integer(std::move(_r));
105 }

◆ rationals()

RCP<const Rationals> SymEngine::rationals ( )
inline
Returns
RCP<const Rationals>

Definition at line 443 of file sets.h.

444 {
445  return Rationals::getInstance();
446 }

◆ reals()

RCP<const Reals> SymEngine::reals ( )
inline
Returns
RCP<const Reals>

Definition at line 437 of file sets.h.

438 {
439  return Reals::getInstance();
440 }

◆ sdiff()

RCP< const Basic > SymEngine::sdiff ( const RCP< const Basic > &  arg,
const RCP< const Basic > &  x,
bool  cache 
)

SymPy style differentiation for non-symbol variables.

SymPy style differentiation w.r.t non-symbols and symbols.

Definition at line 758 of file derivative.cpp.

760 {
761  if (is_a<Symbol>(*x)) {
762  return arg->diff(rcp_static_cast<const Symbol>(x), cache);
763  } else {
764  RCP<const Symbol> d = get_dummy(*arg, "x");
765  return ssubs(ssubs(arg, {{x, d}})->diff(d, cache), {{d, x}});
766  }
767 }
RCP< const Basic > ssubs(const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache=true)
SymPy compatible subs.
Definition: subs.h:511

◆ sqrt()

RCP< const Basic > SymEngine::sqrt ( const RCP< const Basic > &  x)
inline
Returns
sqrt of the arg
square root of x

Definition at line 61 of file pow.h.

62 {
63  return pow(x, div(one, integer(2)));
64 }

◆ sub()

RCP< const Basic > sub ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
)

Substracts b from a.

This essentially implements the addition of a and -b. Note that since this calls add() it performs canonicalization if required.

Parameters
ais the minuend.
bis the subtrahend.
Returns
the difference a-b.

Definition at line 497 of file add.cpp.

498 {
499  return add(a, mul(minus_one, b));
500 }

◆ trig_to_sqrt()

RCP< const Basic > SymEngine::trig_to_sqrt ( const RCP< const Basic > &  arg)
Returns
simplified form if possible

Definition at line 1201 of file functions.cpp.

1202 {
1203  RCP<const Basic> i_arg;
1204 
1205  if (is_a<Sin>(*arg)) {
1206  if (is_a<ACos>(*arg->get_args()[0])) {
1207  i_arg = down_cast<const ACos &>(*(arg->get_args()[0])).get_arg();
1208  return sqrt(sub(one, pow(i_arg, i2)));
1209  } else if (is_a<ATan>(*arg->get_args()[0])) {
1210  i_arg = down_cast<const ATan &>(*(arg->get_args()[0])).get_arg();
1211  return div(i_arg, sqrt(add(one, pow(i_arg, i2))));
1212  } else if (is_a<ASec>(*arg->get_args()[0])) {
1213  i_arg = down_cast<const ASec &>(*(arg->get_args()[0])).get_arg();
1214  return sqrt(sub(one, pow(i_arg, im2)));
1215  } else if (is_a<ACot>(*arg->get_args()[0])) {
1216  i_arg = down_cast<const ACot &>(*(arg->get_args()[0])).get_arg();
1217  return div(one, mul(i_arg, sqrt(add(one, pow(i_arg, im2)))));
1218  }
1219  } else if (is_a<Cos>(*arg)) {
1220  if (is_a<ASin>(*arg->get_args()[0])) {
1221  i_arg = down_cast<const ASin &>(*(arg->get_args()[0])).get_arg();
1222  return sqrt(sub(one, pow(i_arg, i2)));
1223  } else if (is_a<ATan>(*arg->get_args()[0])) {
1224  i_arg = down_cast<const ATan &>(*(arg->get_args()[0])).get_arg();
1225  return div(one, sqrt(add(one, pow(i_arg, i2))));
1226  } else if (is_a<ACsc>(*arg->get_args()[0])) {
1227  i_arg = down_cast<const ACsc &>(*(arg->get_args()[0])).get_arg();
1228  return sqrt(sub(one, pow(i_arg, im2)));
1229  } else if (is_a<ACot>(*arg->get_args()[0])) {
1230  i_arg = down_cast<const ACot &>(*(arg->get_args()[0])).get_arg();
1231  return div(one, sqrt(add(one, pow(i_arg, im2))));
1232  }
1233  } else if (is_a<Tan>(*arg)) {
1234  if (is_a<ASin>(*arg->get_args()[0])) {
1235  i_arg = down_cast<const ASin &>(*(arg->get_args()[0])).get_arg();
1236  return div(i_arg, sqrt(sub(one, pow(i_arg, i2))));
1237  } else if (is_a<ACos>(*arg->get_args()[0])) {
1238  i_arg = down_cast<const ACos &>(*(arg->get_args()[0])).get_arg();
1239  return div(sqrt(sub(one, pow(i_arg, i2))), i_arg);
1240  } else if (is_a<ACsc>(*arg->get_args()[0])) {
1241  i_arg = down_cast<const ACsc &>(*(arg->get_args()[0])).get_arg();
1242  return div(one, mul(i_arg, sqrt(sub(one, pow(i_arg, im2)))));
1243  } else if (is_a<ASec>(*arg->get_args()[0])) {
1244  i_arg = down_cast<const ASec &>(*(arg->get_args()[0])).get_arg();
1245  return mul(i_arg, sqrt(sub(one, pow(i_arg, im2))));
1246  }
1247  } else if (is_a<Csc>(*arg)) {
1248  if (is_a<ACos>(*arg->get_args()[0])) {
1249  i_arg = down_cast<const ACos &>(*(arg->get_args()[0])).get_arg();
1250  return div(one, sqrt(sub(one, pow(i_arg, i2))));
1251  } else if (is_a<ATan>(*arg->get_args()[0])) {
1252  i_arg = down_cast<const ATan &>(*(arg->get_args()[0])).get_arg();
1253  return div(sqrt(add(one, pow(i_arg, i2))), i_arg);
1254  } else if (is_a<ASec>(*arg->get_args()[0])) {
1255  i_arg = down_cast<const ASec &>(*(arg->get_args()[0])).get_arg();
1256  return div(one, sqrt(sub(one, pow(i_arg, im2))));
1257  } else if (is_a<ACot>(*arg->get_args()[0])) {
1258  i_arg = down_cast<const ACot &>(*(arg->get_args()[0])).get_arg();
1259  return mul(i_arg, sqrt(add(one, pow(i_arg, im2))));
1260  }
1261  } else if (is_a<Sec>(*arg)) {
1262  if (is_a<ASin>(*arg->get_args()[0])) {
1263  i_arg = down_cast<const ASin &>(*(arg->get_args()[0])).get_arg();
1264  return div(one, sqrt(sub(one, pow(i_arg, i2))));
1265  } else if (is_a<ATan>(*arg->get_args()[0])) {
1266  i_arg = down_cast<const ATan &>(*(arg->get_args()[0])).get_arg();
1267  return sqrt(add(one, pow(i_arg, i2)));
1268  } else if (is_a<ACsc>(*arg->get_args()[0])) {
1269  i_arg = down_cast<const ACsc &>(*(arg->get_args()[0])).get_arg();
1270  return div(one, sqrt(sub(one, pow(i_arg, im2))));
1271  } else if (is_a<ACot>(*arg->get_args()[0])) {
1272  i_arg = down_cast<const ACot &>(*(arg->get_args()[0])).get_arg();
1273  return sqrt(add(one, pow(i_arg, im2)));
1274  }
1275  } else if (is_a<Cot>(*arg)) {
1276  if (is_a<ASin>(*arg->get_args()[0])) {
1277  i_arg = down_cast<const ASin &>(*(arg->get_args()[0])).get_arg();
1278  return div(sqrt(sub(one, pow(i_arg, i2))), i_arg);
1279  } else if (is_a<ACos>(*arg->get_args()[0])) {
1280  i_arg = down_cast<const ACos &>(*(arg->get_args()[0])).get_arg();
1281  return div(i_arg, sqrt(sub(one, pow(i_arg, i2))));
1282  } else if (is_a<ACsc>(*arg->get_args()[0])) {
1283  i_arg = down_cast<const ACsc &>(*(arg->get_args()[0])).get_arg();
1284  return mul(i_arg, sqrt(sub(one, pow(i_arg, im2))));
1285  } else if (is_a<ASec>(*arg->get_args()[0])) {
1286  i_arg = down_cast<const ASec &>(*(arg->get_args()[0])).get_arg();
1287  return div(one, mul(i_arg, sqrt(sub(one, pow(i_arg, im2)))));
1288  }
1289  }
1290 
1291  return arg;
1292 }
RCP< const Basic > sub(const RCP< const Basic > &a, const RCP< const Basic > &b)
Substracts b from a.
Definition: add.cpp:497
RCP< const Basic > sqrt(const RCP< const Basic > &arg)
Definition: pow.h:61

◆ unified_compare()

template<typename T , typename = enable_if_t<std::is_arithmetic<T>::value or std::is_same<T, integer_class>::value or std::is_same<T, rational_class>::value>>
int SymEngine::unified_compare ( const T &  a,
const T &  b 
)
inline

compare functions base

Returns
-1, 0, 1 for a < b, a == b, a > b

Definition at line 205 of file dict.h.

206 {
207  if (a == b)
208  return 0;
209  return a < b ? -1 : 1;
210 }

◆ universalset()

RCP<const UniversalSet> SymEngine::universalset ( )
inline
Returns
RCP<const UniversalSet>

Definition at line 461 of file sets.h.

462 {
463  return UniversalSet::getInstance();
464 }

◆ unordered_eq()

template<class T >
bool SymEngine::unordered_eq ( const T &  a,
const T &  b 
)
inline

eq function base

Returns
true if the two dictionaries a and b are equal. Otherwise false

Definition at line 156 of file dict.h.

157 {
158  // This follows the same algorithm as Python's dictionary comparison
159  // (a==b), which is implemented by "dict_equal" function in
160  // Objects/dictobject.c.
161 
162  // Can't be equal if # of entries differ:
163  if (a.size() != b.size())
164  return false;
165  // Loop over keys in "a":
166  for (const auto &p : a) {
167  // O(1) lookup of the key in "b":
168  auto f = b.find(p.first);
169  if (f == b.end())
170  return false; // no such element in "b"
171  if (not unified_eq(p.second, f->second))
172  return false; // values not equal
173  }
174  return true;
175 }

Variable Documentation

◆ inverse_cst

umap_basic_basic SymEngine::inverse_cst
Initial value:
= {
{C3, i3},
{mC3, im3},
{C2, mul(i2, i2)},
{mC2, mul(im2, i2)},
{C4, integer(12)},
{mC4, integer(-12)},
{C5, i5},
{mC5, im5},
{C6, integer(10)},
{mC6, integer(-10)},
{div(one, i2), integer(6)},
{div(minus_one, i2), integer(-6)},
}

Definition at line 99 of file constants.cpp.

◆ inverse_tct

umap_basic_basic SymEngine::inverse_tct
Initial value:
= {
{div(one, sq3), mul(i2, i3)},
{div(minus_one, sq3), mul(im2, i3)},
{sq3, i3},
{mul(minus_one, sq3), im3},
{add(one, sq2), div(pow(i2, i3), i3)},
{mul(minus_one, add(one, sq2)), div(pow(i2, i3), im3)},
{sub(sq2, one), pow(i2, i3)},
{sub(one, sq2), pow(im2, i3)},
{sub(i2, sq3), mul(mul(i2, i2), i3)},
{sub(sq3, i2), mul(mul(im2, i2), i3)},
{sqrt(add(i5, mul(i2, sqrt(i5)))), div(i5, i2)},
{mul(minus_one, sqrt(add(i5, mul(i2, sqrt(i5))))), div(im5, i2)},
{one, pow(i2, i2)},
{minus_one, mul(minus_one, pow(i2, i2))},
}

Definition at line 114 of file constants.cpp.

◆ sin_table

RCP< const Basic > SymEngine::sin_table
Initial value:
= {zero, C0, C1, C2, C3, C4, one, C4, C3, C2, C1, C0,
zero, mC0, mC1, mC2, mC3, mC4, minus_one, mC4, mC3, mC2, mC1, mC0}

Definition at line 95 of file constants.cpp.