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  PrimePi
 
class  Primorial
 
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  Sieve
 
class  CodePrinter
 
class  C89CodePrinter
 
class  C99CodePrinter
 
class  JSCodePrinter
 
class  LatexPrinter
 
class  MathMLPrinter
 
class  SbmlPrinter
 
class  StringBox
 
struct  PrinterBasicCmp
 Less operator (<) using cmp: More...
 
class  Precedence
 
class  StrPrinter
 
class  JuliaStrPrinter
 
class  UnicodePrinter
 
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  RefineVisitor
 
class  RewriteAsExp
 
class  RewriteAsSin
 
class  RewriteAsCos
 
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  IntegerVisitor
 
class  RealVisitor
 
class  ComplexVisitor
 
class  PolynomialVisitor
 
class  RationalVisitor
 
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 std::unordered_map< RCP< const Basic >, bool, RCPBasicHash, RCPBasicKeyEqumap_basic_bool
 
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 pow_number (const RCP< const Basic > &in_re, const RCP< const Basic > &in_im, unsigned long n, Ptr< RCP< const Basic >> &out_re, Ptr< RCP< const Basic >> &out_im)
 
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)
 
RCP< const Basicrewrite_as_sin (const RCP< const Basic > &x)
 
RCP< const Basicrewrite_as_cos (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)
 
integer_class mp_primorial (unsigned long n)
 
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 Basicprimorial (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, const Assumptions *assumptions=nullptr)
 Check if a number is zero. More...
 
tribool is_nonzero (const Basic &b, const Assumptions *assumptions=nullptr)
 Check if a number is non-zero. More...
 
tribool is_positive (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_nonpositive (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_negative (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_nonnegative (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_integer (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_real (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_complex (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_rational (const Basic &b)
 
tribool is_irrational (const Basic &b)
 
RCP< const Basicparse (const std::string &s, bool convert_xor=true, const std::map< const std::string, const RCP< const Basic >> &constants={})
 
RCP< const Basicparse_old (const std::string &s, bool convert_xor=true)
 
RCP< const Basicparse_sbml (const std::string &s, const std::map< const std::string, const RCP< const Basic >> &constants={})
 
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)
 
static std::vector< std::stringinit_sbml_printer_names ()
 
std::string sbml (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)
 
static std::vector< std::stringinit_unicode_printer_names ()
 
std::vector< size_t > init_unicode_printer_lengths (const std::vector< std::string > &names)
 
std::string unicode (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)
 
RCP< const Basicrefine (const RCP< const Basic > &x, const Assumptions *assumptions)
 
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 Integertwo = integer(2)
 
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 425 of file add.cpp.

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

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

◆ 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 493 of file ntheory.cpp.

494 {
495 #ifdef HAVE_SYMENGINE_ARB
496  fmpq_t res;
497  fmpq_init(res);
498  bernoulli_fmpq_ui(res, n);
499  mpq_t a;
500  mpq_init(a);
501  fmpq_get_mpq(a, res);
502  rational_class b(a);
503  fmpq_clear(res);
504  mpq_clear(a);
505  return Rational::from_mpq(std::move(b));
506 #else
507  // TODO: implement a faster algorithm
509  for (unsigned m = 0; m <= n; ++m) {
510  v[m] = rational_class(1u, m + 1);
511 
512  for (unsigned j = m; j >= 1; --j) {
513  v[j - 1] = j * (v[j - 1] - v[j]);
514  }
515  }
516  return Rational::from_mpq(v[0]);
517 #endif
518 }

◆ 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:200
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 1382 of file sets.cpp.

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

◆ could_extract_minus()

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

Definition at line 282 of file functions.cpp.

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

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

◆ emptyset()

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

Definition at line 454 of file sets.h.

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

◆ 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 368 of file ntheory.cpp.

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

◆ 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 419 of file ntheory.cpp.

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

◆ finiteset()

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

Definition at line 466 of file sets.h.

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

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

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

◆ 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 200 of file integer.h.

201 {
202  return make_rcp<const Integer>(integer_class(i));
203 }

◆ integers()

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

Definition at line 448 of file sets.h.

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

◆ 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 475 of file sets.h.

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

◆ 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 437 of file functions.cpp.

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

◆ 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_nonzero()

tribool SymEngine::is_nonzero ( const Basic b,
const Assumptions assumptions = nullptr 
)

Check if a number is non-zero.

Parameters
bBasic
assumptionsAssumptions
Returns
tribool

Check if b is non-zero. If b is not numeric an exception will be thrown.

Definition at line 88 of file test_visitors.cpp.

89 {
90  ZeroVisitor visitor(assumptions);
91  return not_tribool(visitor.apply(b));
92 }

◆ 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 700 of file test_visitors.cpp.

701 {
702  PolynomialVisitor visitor(variables);
703  return visitor.apply(b);
704 }

◆ is_zero()

tribool SymEngine::is_zero ( const Basic b,
const Assumptions assumptions = nullptr 
)

Check if a number is zero.

Parameters
bBasic
assumptionsAssumptions
Returns
tribool

Check if b is zero. If b is not numeric an exception will be thrown.

Definition at line 82 of file test_visitors.cpp.

83 {
84  ZeroVisitor visitor(assumptions);
85  return visitor.apply(b);
86 }

◆ 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 1774 of file functions.cpp.

1775 {
1776  return div(log(arg), log(base));
1777 }
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 170 of file ntheory.cpp.

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

◆ 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 1431 of file ntheory.cpp.

1433 {
1434  if (is_a<Integer>(*b)) {
1435  integer_class t = down_cast<const Integer &>(*b).as_integer_class();
1436  if (b->is_negative())
1437  t *= -1;
1438  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1439  if (b->is_negative()) {
1440  bool ret_val = mp_invert(t, t, m->as_integer_class());
1441  if (not ret_val)
1442  return false;
1443  }
1444  *powm = integer(std::move(t));
1445  return true;
1446  } else if (is_a<Rational>(*b)) {
1447  RCP<const Integer> num, den, r;
1448  get_num_den(down_cast<const Rational &>(*b), outArg(num), outArg(den));
1449  if (den->is_negative()) {
1450  den = den->mulint(*minus_one);
1451  num = num->mulint(*minus_one);
1452  }
1453  integer_class t = mp_abs(num->as_integer_class());
1454  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1455  if (num->is_negative()) {
1456  bool ret_val = mp_invert(t, t, m->as_integer_class());
1457  if (not ret_val)
1458  return false;
1459  }
1460  r = integer(std::move(t));
1461  return nthroot_mod(powm, r, den, m);
1462  }
1463  return false;
1464 }
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:130
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:1369

◆ 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 1466 of file ntheory.cpp.

1469 {
1470  if (is_a<Integer>(*b)) {
1471  integer_class t
1472  = mp_abs(down_cast<const Integer &>(*b).as_integer_class());
1473  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1474  if (b->is_negative()) {
1475  bool ret_val = mp_invert(t, t, m->as_integer_class());
1476  if (not ret_val)
1477  return;
1478  }
1479  pows.push_back(integer(std::move(t)));
1480  } else if (is_a<Rational>(*b)) {
1481  RCP<const Integer> num, den, r;
1482  get_num_den(down_cast<const Rational &>(*b), outArg(num), outArg(den));
1483  if (den->is_negative()) {
1484  den = den->mulint(*integer(-1));
1485  num = num->mulint(*integer(-1));
1486  }
1487  integer_class t = num->as_integer_class();
1488  if (num->is_negative())
1489  t *= -1;
1490  mp_powm(t, a->as_integer_class(), t, m->as_integer_class());
1491  if (num->is_negative()) {
1492  bool ret_val = mp_invert(t, t, m->as_integer_class());
1493  if (not ret_val)
1494  return;
1495  }
1496  r = integer(t);
1497  nthroot_mod_list(pows, r, den, m);
1498  }
1499 }
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:1399
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 762 of file ntheory.cpp.

764 {
765  integer_class _n = n.as_integer_class();
766  if (_n < 0)
767  _n = -_n;
768  if (_n <= 1)
769  return;
770  if (_n < 5) {
771  roots.push_back(integer(_n - 1));
772  return;
773  }
774  bool even = false;
775  if (_n % 2 == 0) {
776  if (_n % 4 == 0) {
777  return; // If n%4 == 0 and n > 4, then no primitive roots.
778  }
779  _n /= 2;
780  even = true;
781  }
782  integer_class p, e;
783  if (not _prime_power(p, e, _n))
784  return;
785  _primitive_root_list(roots, p, e, even);
786  std::sort(roots.begin(), roots.end(), SymEngine::RCPIntegerKeyLess());
787  return;
788 }
T begin(T... args)
T sort(T... args)
less operator (<) for Integers
Definition: integer.h:188

◆ 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 69 of file ntheory.cpp.

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

◆ 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 91 of file ntheory.cpp.

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

◆ 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 74 of file ntheory.cpp.

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

◆ 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 98 of file ntheory.cpp.

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

◆ rationals()

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

Definition at line 442 of file sets.h.

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

◆ reals()

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

Definition at line 436 of file sets.h.

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

◆ 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:543

◆ 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 495 of file add.cpp.

496 {
497  return add(a, mul(minus_one, b));
498 }

◆ trig_to_sqrt()

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

Definition at line 1203 of file functions.cpp.

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

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

◆ 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 98 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 113 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 94 of file constants.cpp.