Loading...
Searching...
No Matches
SymEngine Namespace Reference

Main namespace for SymEngine package. More...

Data Structures

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

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 class  EvalfDomain { Complex = 0 , Real = 1 , Symbolic = 2 }
 
enum class  PrecedenceEnum {
  Relational , Add , Mul , Pow ,
  Atom
}
 
enum class  tribool { indeterminate = -1 , trifalse = 0 , tritrue = 1 }
 

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. More...
 
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. More...
 
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 More...
 
std::string type_code_name (TypeID id)
 
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. More...
 
RCP< const Basicexpand (const RCP< const Basic > &self, bool deep=true)
 Expands self More...
 
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 More...
 
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. More...
 
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 More...
 
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 More...
 
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)
 
static 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)
 
static const RCP< const Basic > * sin_table ()
 
static const umap_basic_basicinverse_cst ()
 
static const umap_basic_basicinverse_tct ()
 
RCP< const Basicconjugate (const RCP< const Basic > &arg)
 Canonicalize Conjugate. More...
 
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 (const 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. More...
 
RCP< const Basicfloor (const RCP< const Basic > &arg)
 Canonicalize Floor: More...
 
RCP< const Basicceiling (const RCP< const Basic > &arg)
 Canonicalize Ceiling: More...
 
RCP< const Basictruncate (const RCP< const Basic > &arg)
 Canonicalize Truncate: More...
 
RCP< const Basicsin (const RCP< const Basic > &arg)
 Canonicalize Sin: More...
 
RCP< const Basiccos (const RCP< const Basic > &arg)
 Canonicalize Cos: More...
 
RCP< const Basictan (const RCP< const Basic > &arg)
 Canonicalize Tan: More...
 
RCP< const Basiccot (const RCP< const Basic > &arg)
 Canonicalize Cot: More...
 
RCP< const Basiccsc (const RCP< const Basic > &arg)
 Canonicalize Csc: More...
 
RCP< const Basicsec (const RCP< const Basic > &arg)
 Canonicalize Sec: More...
 
RCP< const Basictrig_to_sqrt (const RCP< const Basic > &arg)
 
RCP< const Basicasin (const RCP< const Basic > &arg)
 Canonicalize ASin: More...
 
RCP< const Basicacos (const RCP< const Basic > &arg)
 Canonicalize ACos: More...
 
RCP< const Basicasec (const RCP< const Basic > &arg)
 Canonicalize ASec: More...
 
RCP< const Basicacsc (const RCP< const Basic > &arg)
 Canonicalize ACsc: More...
 
RCP< const Basicatan (const RCP< const Basic > &arg)
 Canonicalize ATan: More...
 
RCP< const Basicacot (const RCP< const Basic > &arg)
 Canonicalize ACot: More...
 
RCP< const Basicatan2 (const RCP< const Basic > &num, const RCP< const Basic > &den)
 Canonicalize ATan2: More...
 
RCP< const Basiclog (const RCP< const Basic > &arg)
 Returns the Natural Logarithm from argument arg More...
 
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: More...
 
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: More...
 
RCP< const Basicsinh (const RCP< const Basic > &arg)
 Canonicalize Sinh: More...
 
RCP< const Basiccsch (const RCP< const Basic > &arg)
 Canonicalize Csch: More...
 
RCP< const Basiccosh (const RCP< const Basic > &arg)
 Canonicalize Cosh: More...
 
RCP< const Basicsech (const RCP< const Basic > &arg)
 Canonicalize Sech: More...
 
RCP< const Basictanh (const RCP< const Basic > &arg)
 Canonicalize Tanh: More...
 
RCP< const Basiccoth (const RCP< const Basic > &arg)
 Canonicalize Coth: More...
 
RCP< const Basicasinh (const RCP< const Basic > &arg)
 Canonicalize ASinh: More...
 
RCP< const Basicacsch (const RCP< const Basic > &arg)
 Canonicalize ACsch: More...
 
RCP< const Basicacosh (const RCP< const Basic > &arg)
 Canonicalize ACosh: More...
 
RCP< const Basicatanh (const RCP< const Basic > &arg)
 Canonicalize ATanh: More...
 
RCP< const Basicacoth (const RCP< const Basic > &arg)
 Canonicalize ACoth: More...
 
RCP< const Basicasech (const RCP< const Basic > &arg)
 Canonicalize ASech: More...
 
RCP< const Basickronecker_delta (const RCP< const Basic > &i, const RCP< const Basic > &j)
 Canonicalize KroneckerDelta: More...
 
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: More...
 
RCP< const Basiczeta (const RCP< const Basic > &s, const RCP< const Basic > &a)
 Create a new Zeta instance: More...
 
RCP< const Basiczeta (const RCP< const Basic > &s)
 
RCP< const Basicdirichlet_eta (const RCP< const Basic > &s)
 Create a new Dirichlet_eta instance: More...
 
RCP< const Basicerf (const RCP< const Basic > &arg)
 Canonicalize Erf: More...
 
RCP< const Basicerfc (const RCP< const Basic > &arg)
 Canonicalize Erfc: More...
 
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: More...
 
RCP< const Basiclowergamma (const RCP< const Basic > &s, const RCP< const Basic > &x)
 Canonicalize LowerGamma: More...
 
RCP< const Basicuppergamma (const RCP< const Basic > &s, const RCP< const Basic > &x)
 Canonicalize UpperGamma: More...
 
RCP< const Basicloggamma (const RCP< const Basic > &arg)
 Canonicalize LogGamma: More...
 
RCP< const Basicbeta (const RCP< const Basic > &x, const RCP< const Basic > &y)
 Canonicalize Beta: More...
 
RCP< const Basicpolygamma (const RCP< const Basic > &n, const RCP< const Basic > &x)
 Canonicalize PolyGamma. More...
 
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: More...
 
RCP< const Basicmax (const vec_basic &arg)
 Canonicalize Max: More...
 
RCP< const Basicmin (const vec_basic &arg)
 Canonicalize Min: More...
 
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. More...
 
RCP< const Integeriabs (const Integer &n)
 Integer Absolute value. More...
 
int i_nth_root (const Ptr< RCP< const Integer > > &r, const Integer &a, unsigned long int n)
 Integer nth root. More...
 
bool perfect_square (const Integer &n)
 Perfect Square. More...
 
bool perfect_power (const Integer &n)
 Perfect Square. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::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)
 
RCP< const Basicpiecewise (const PiecewiseVec &vec)
 
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. More...
 
RCP< const BooleanEq (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized Equality object from the two arguments. More...
 
RCP< const BooleanNe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized Unequality object from the arguments. More...
 
RCP< const BooleanLe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized LessThan object from the arguments. More...
 
RCP< const BooleanGe (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Convenience function returning LessThan object. More...
 
RCP< const BooleanLt (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Returns the canonicalized StrictLessThan object from the arguments. More...
 
RCP< const BooleanGt (const RCP< const Basic > &lhs, const RCP< const Basic > &rhs)
 Convenience function returning StrictLessThan object. More...
 
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)
 
bool is_a_Relational (const Basic &b)
 
bool is_a_Boolean (const Basic &b)
 
RCP< const MatrixExprconjugate_matrix (const RCP< const MatrixExpr > &arg)
 
bool is_zero_vec (const vec_basic &container)
 
bool is_identity_vec (const vec_basic &container)
 
RCP< const MatrixExprdiagonal_matrix (const vec_basic &container)
 
void check_matching_sizes (const vec_basic &vec)
 
RCP< const MatrixExprhadamard_product (const vec_basic &factors)
 
RCP< const MatrixExpridentity_matrix (const RCP< const Basic > &n)
 
bool is_identity_dense (size_t n, const vec_basic &container)
 
bool is_diagonal_dense (size_t n, const vec_basic &container)
 
vec_basic extract_diagonal (size_t n, const vec_basic &container)
 
RCP< const MatrixExprimmutable_dense_matrix (size_t m, size_t n, const vec_basic &container)
 
tribool is_diagonal (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_lower (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_real (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_square (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_symmetric (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_toeplitz (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_upper (const MatrixExpr &m, const Assumptions *assumptions)
 
tribool is_zero (const MatrixExpr &m, const Assumptions *assumptions)
 
RCP< const MatrixExprmatrix_add (const vec_basic &terms)
 
bool is_a_MatrixExpr (const Basic &b)
 
RCP< const DiagonalMatrixmul_diag_diag (const DiagonalMatrix &A, const DiagonalMatrix &B)
 
RCP< const ImmutableDenseMatrixmul_dense_dense (const ImmutableDenseMatrix &A, const ImmutableDenseMatrix &B)
 
RCP< const ImmutableDenseMatrixmul_diag_dense (const DiagonalMatrix &A, const ImmutableDenseMatrix &B)
 
RCP< const ImmutableDenseMatrixmul_dense_diag (const ImmutableDenseMatrix &A, const DiagonalMatrix &B)
 
void check_matching_mul_sizes (const vec_basic &vec)
 
RCP< const MatrixExprmatrix_mul (const vec_basic &factors)
 
RCP< const MatrixExprmatrix_symbol (const std::string &name)
 
std::pair< RCP< const Basic >, RCP< const Basic > > size (const MatrixExpr &m)
 
RCP< const Basictrace (const RCP< const MatrixExpr > &arg)
 
RCP< const MatrixExprtranspose (const RCP< const MatrixExpr > &arg)
 
RCP< const MatrixExprzero_matrix (const RCP< const Basic > &m, const RCP< const Basic > &n)
 
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. More...
 
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. More...
 
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_set_str (integer_class &i, const std::string &a)
 
std::string mp_get_hex_str (const integer_class &i)
 
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. More...
 
RCP< const Basicmul (const vec_basic &a)
 
RCP< const Basicdiv (const RCP< const Basic > &a, const RCP< const Basic > &b)
 Division. More...
 
RCP< const Basicneg (const RCP< const Basic > &a)
 Negation. More...
 
RCP< const Integergcd (const Integer &a, const Integer &b)
 Greatest Common Divisor. More...
 
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. More...
 
RCP< const Integerlcm (const Integer &a, const Integer &b)
 Least Common Multiple. More...
 
int mod_inverse (const Ptr< RCP< const Integer > > &b, const Integer &a, const Integer &m)
 inverse modulo More...
 
RCP< const Integermod (const Integer &n, const Integer &d)
 modulo round toward zero More...
 
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 More...
 
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. More...
 
void fibonacci2 (const Ptr< RCP< const Integer > > &g, const Ptr< RCP< const Integer > > &s, unsigned long n)
 Fibonacci n and n-1. More...
 
RCP< const Integerlucas (unsigned long n)
 Lucas number. More...
 
void lucas2 (const Ptr< RCP< const Integer > > &g, const Ptr< RCP< const Integer > > &s, unsigned long n)
 Lucas number n and n-1. More...
 
RCP< const Integerbinomial (const Integer &n, unsigned long k)
 Binomial Coefficient. More...
 
RCP< const Integerfactorial (unsigned long n)
 Factorial. More...
 
bool divides (const Integer &a, const Integer &b)
 
int probab_prime_p (const Integer &a, unsigned reps=25)
 Probabilistic Prime. More...
 
RCP< const Integernextprime (const Integer &a)
 
int factor_lehman_method (const Ptr< RCP< const Integer > > &f, const Integer &n)
 Factor using lehman's methods. More...
 
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. More...
 
int factor_pollard_rho_method (const Ptr< RCP< const Integer > > &f, const Integer &n, unsigned retries=5)
 Factor using Pollard's rho methods. More...
 
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 More...
 
void prime_factor_multiplicities (map_integer_uint &primes, const Integer &n)
 Find multiplicities of prime factors of n More...
 
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. More...
 
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. More...
 
bool primitive_root (const Ptr< RCP< const Integer > > &g, const Integer &n)
 Computes a primitive root. Returns false if no primitive root exists. More...
 
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. More...
 
RCP< const Integercarmichael (const RCP< const Integer > &n)
 Carmichael function. More...
 
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. More...
 
int legendre (const Integer &a, const Integer &n)
 Legendre Function. More...
 
int jacobi (const Integer &a, const Integer &n)
 Jacobi Function. More...
 
int kronecker (const Integer &a, const Integer &n)
 Kronecker Function. More...
 
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. More...
 
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. More...
 
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. More...
 
bool is_quad_residue (const Integer &a, const Integer &p)
 Returns true if 'a' is a quadratic residue of 'p'. More...
 
bool is_nth_residue (const Integer &a, const Integer &n, const Integer &mod)
 Returns true if 'a' is a nth power residue of 'mod'. More...
 
int mobius (const Integer &a)
 Mobius Function. More...
 
long mertens (const unsigned long a)
 
integer_class mp_polygonal_number (const integer_class &s, const integer_class &n)
 Numeric calculation of the n:th s-gonal number. More...
 
integer_class mp_principal_polygonal_root (const integer_class &s, const integer_class &x)
 Numeric calculation of the principal s-gonal root of x. More...
 
std::pair< integer_class, integer_class > mp_perfect_power_decomposition (const integer_class &n, bool lowest_exponent=false)
 Decompose a positive integer into perfect powers. More...
 
RCP< const Basicprimepi (const RCP< const Basic > &arg)
 
RCP< const Basicprimorial (const RCP< const Basic > &arg)
 
RCP< const Basicpolygonal_number (const RCP< const Basic > &s, const RCP< const Basic > &n)
 The n:th s-gonal number. More...
 
RCP< const Basicprincipal_polygonal_root (const RCP< const Basic > &s, const RCP< const Basic > &x)
 The principal s-gonal root of x. More...
 
RCP< const Numberaddnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Add self and other More...
 
RCP< const Numbersubnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Subtract self and other More...
 
RCP< const Numbermulnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Multiply self and other More...
 
RCP< const Numberdivnum (const RCP< const Number > &self, const RCP< const Number > &other)
 Divide self and other More...
 
RCP< const Numberpownum (const RCP< const Number > &self, const RCP< const Number > &other)
 Raise self to power other More...
 
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)
 
tribool is_finite (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_infinite (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_even (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_odd (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_algebraic (const Basic &b, const Assumptions *assumptions=nullptr)
 
tribool is_transcendental (const Basic &b, const Assumptions *assumptions=nullptr)
 
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) More...
 
RCP< const Basicpow_expand (const RCP< const Pow > &self)
 Expand the power expression.
 
static std::vector< unsigned > & sieve_primes ()
 
std::string str (const Basic &x)
 
std::string str (const DenseMatrix &x)
 
std::string unicode (const Basic &x)
 
std::string julia_str (const Basic &x)
 
std::string sbml (const Basic &x)
 
std::string ascii_art ()
 
std::string mathml (const Basic &x)
 
std::string latex (const Basic &x)
 
std::string latex (const DenseMatrix &x, const unsigned max_rows=20, const unsigned max_cols=12)
 
std::string ccode (const Basic &x)
 
std::string c89code (const Basic &x)
 
std::string c99code (const Basic &x)
 
std::string jscode (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 ()
 
static std::vector< std::stringinit_sbml_printer_names ()
 
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 ()
 
static std::vector< std::stringinit_unicode_printer_names ()
 
static std::vector< size_t > init_unicode_printer_lengths (const std::vector< std::string > &names)
 
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> More...
 
RCP< const Numberrational (long n, long d)
 convenience creator from two longs More...
 
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 More...
 
void poly_mul (const umap_vec_mpz &A, const umap_vec_mpz &B, umap_vec_mpz &C)
 Multiply two polynomials: C = A*B More...
 
template<class Archive >
void save_basic (Archive &ar, const Basic &b)
 
template<class Archive >
void save_basic (Archive &ar, const Symbol &b)
 
template<class Archive >
void save_basic (Archive &ar, const Mul &b)
 
template<class Archive >
void save_basic (Archive &ar, const Add &b)
 
template<class Archive >
void save_basic (Archive &ar, const Pow &b)
 
template<typename Archive >
void save_helper (Archive &ar, const integer_class &intgr)
 
template<typename Archive >
void save_helper (Archive &ar, const rational_class &rat)
 
template<typename Archive >
void save_basic (Archive &ar, const URatPoly &b)
 
template<class Archive >
void save_basic (Archive &ar, const Integer &b)
 
template<class Archive >
void save_basic (Archive &ar, const RealDouble &b)
 
template<class Archive >
void save_basic (Archive &ar, const Rational &b)
 
template<class Archive >
void save_basic (Archive &ar, const ComplexBase &b)
 
template<class Archive >
void save_basic (Archive &ar, const Interval &b)
 
template<class Archive >
void save_basic (Archive &ar, const BooleanAtom &b)
 
template<class Archive >
void save_basic (Archive &ar, const Infty &b)
 
template<class Archive >
void save_basic (Archive &ar, const NaN &b)
 
template<class Archive >
void save_basic (Archive &ar, const Constant &b)
 
template<class Archive >
void save_basic (Archive &ar, const OneArgFunction &b)
 
template<class Archive >
void save_basic (Archive &ar, const TwoArgFunction &b)
 
template<class Archive >
void save_basic (Archive &ar, const Relational &b)
 
template<class Archive >
void save_basic (Archive &ar, const And &b)
 
template<class Archive >
void save_basic (Archive &ar, const Or &b)
 
template<class Archive >
void save_basic (Archive &ar, const Xor &b)
 
template<class Archive >
void save_basic (Archive &ar, const Not &b)
 
template<class Archive >
void save_basic (Archive &ar, const Contains &b)
 
template<class Archive >
void save_basic (Archive &ar, const Piecewise &b)
 
template<class Archive >
void save_basic (Archive &ar, const Reals &b)
 
template<class Archive >
void save_basic (Archive &ar, const Rationals &b)
 
template<class Archive >
void save_basic (Archive &ar, const EmptySet &b)
 
template<class Archive >
void save_basic (Archive &ar, const Integers &b)
 
template<class Archive >
void save_basic (Archive &ar, const UniversalSet &b)
 
template<class Archive >
void save_basic (Archive &ar, const Union &b)
 
template<class Archive >
void save_basic (Archive &ar, const Complement &b)
 
template<class Archive >
void save_basic (Archive &ar, const ImageSet &b)
 
template<class Archive >
void save_basic (Archive &ar, const FiniteSet &b)
 
template<class Archive >
void save_basic (Archive &ar, const ConditionSet &b)
 
template<class Archive >
void save_basic (Archive &ar, const GaloisField &b)
 
template<class Archive >
void save_basic (Archive &ar, const SeriesCoeffInterface &)
 
template<class Archive >
void save_basic (Archive &ar, const MultiArgFunction &b)
 
template<class Archive >
void save_basic (Archive &ar, const FunctionSymbol &b)
 
template<class Archive >
void save_basic (Archive &ar, const Derivative &b)
 
template<class Archive >
void save_basic (Archive &ar, const Subs &b)
 
template<class Archive >
void save_basic (Archive &ar, const NumberWrapper &b)
 
template<class Archive >
void save_basic (Archive &ar, const FunctionWrapper &b)
 
template<class Archive >
void save_basic (Archive &ar, RCP< const Basic > const &ptr)
 
template<class Archive , class T >
void CEREAL_SAVE_FUNCTION_NAME (Archive &ar, RCP< const T > const &ptr)
 Saving for SymEngine::RCP. More...
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const RealDouble > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Infty > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const NaN > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Symbol > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Mul > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Add > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Pow > &)
 
template<typename Archive >
void load_helper (Archive &ar, integer_class &intgr)
 
template<typename Archive >
void load_helper (Archive &ar, const rational_class &rat)
 
template<typename Archive >
RCP< const Basicload_basic (Archive &ar, const URatPoly &b)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Integer > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Constant > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Rational > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Complex > &)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< std::is_base_of< ComplexBase, T >::value, int >::type *=nullptr)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Interval > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const BooleanAtom > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const And > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Or > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Xor > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Not > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Piecewise > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Contains > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Reals > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Rationals > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const EmptySet > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Integers > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const UniversalSet > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Union > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Complement > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const ImageSet > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const FiniteSet > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const ConditionSet > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Derivative > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const Subs > &)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< std::is_base_of< OneArgFunction, T >::value, int >::type *=nullptr)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< std::is_base_of< TwoArgFunction, T >::value, int >::type *=nullptr)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const FunctionSymbol > &)
 
template<class Archive >
RCP< const Basicload_basic (Archive &ar, RCP< const FunctionWrapper > &)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< std::is_base_of< MultiArgFunction, T >::value, int >::type *=nullptr)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< std::is_base_of< Relational, T >::value, int >::type *=nullptr)
 
template<class Archive , class T >
RCP< const Basicload_basic (Archive &ar, RCP< const T > &, typename std::enable_if< not(std::is_base_of< Relational, T >::value or std::is_base_of< ComplexBase, T >::value or std::is_base_of< OneArgFunction, T >::value or std::is_base_of< MultiArgFunction, T >::value or std::is_base_of< TwoArgFunction, T >::value), int >::type *=nullptr)
 
template<class Archive , class T >
void CEREAL_LOAD_FUNCTION_NAME (Archive &ar, RCP< const T > &ptr)
 Loading for SymEngine::RCP. More...
 
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 Basicsup (const Set &s)
 
RCP< const Basicinf (const Set &s)
 
RCP< const Setboundary (const Set &s)
 
RCP< const Setinterior (const Set &s)
 
RCP< const Setclosure (const Set &s)
 
static RCP< const Setmake_set_union (const set_set &in)
 
static RCP< const Setmake_set_intersection (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 Complexescomplexes ()
 
RCP< const Realsreals ()
 
RCP< const Rationalsrationals ()
 
RCP< const Integersintegers ()
 
RCP< const Naturalsnaturals ()
 
RCP< const Naturals0naturals0 ()
 
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 Basicsimplify (const RCP< const Basic > &x, const Assumptions *assumptions)
 
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 More...
 
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. More...
 
RCP< const Basicssubs (const RCP< const Basic > &x, const map_basic_basic &subs_dict, bool cache)
 SymPy compatible subs. More...
 
RCP< const Symbolsymbol (const std::string &name)
 inline version to return Symbol More...
 
RCP< const Dummydummy ()
 inline version to return Dummy More...
 
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...
 
bool is_true (tribool x)
 
bool is_false (tribool x)
 
bool is_indeterminate (tribool x)
 
tribool tribool_from_bool (bool x)
 
tribool and_tribool (tribool a, tribool b)
 
tribool or_tribool (tribool a, tribool b)
 
tribool not_tribool (tribool a)
 
tribool andwk_tribool (tribool a, tribool b)
 
tribool orwk_tribool (tribool a, tribool b)
 
RCP< const Basictuple (const vec_basic &arg)
 
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 = []() { static const RCP<const Integer > c = integer(0) ; return c; }()
 
RCP< const Integerone = []() { static const RCP<const Integer > c = integer(1) ; return c; }()
 
RCP< const Integerminus_one = []() { static const RCP<const Integer > c = integer(-1) ; return c; }()
 
RCP< const Integertwo = []() { static const RCP<const Integer > c = integer(2) ; return c; }()
 
RCP< const NumberI = []() { static const RCP<const Number > c = Complex::from_two_nums(*zero, *one) ; return c; }()
 
RCP< const Constantpi = []() { static const RCP<const Constant > c = constant("pi") ; return c; }()
 
RCP< const ConstantE = []() { static const RCP<const Constant > c = constant("E") ; return c; }()
 
RCP< const ConstantEulerGamma = []() { static const RCP<const Constant > c = constant("EulerGamma") ; return c; }()
 
RCP< const ConstantCatalan = []() { static const RCP<const Constant > c = constant("Catalan") ; return c; }()
 
RCP< const ConstantGoldenRatio = []() { static const RCP<const Constant > c = constant("GoldenRatio") ; return c; }()
 
RCP< const InftyInf = []() { static const RCP<const Infty > c = Infty::from_int(1) ; return c; }()
 
RCP< const InftyNegInf = []() { static const RCP<const Infty > c = Infty::from_int(-1) ; return c; }()
 
RCP< const InftyComplexInf = []() { static const RCP<const Infty > c = Infty::from_int(0) ; return c; }()
 
RCP< const NaNNan = []() { static const RCP<const NaN > c = make_rcp<NaN>() ; return c; }()
 
RCP< const Basici2 = []() { static const RCP<const Basic > c = integer(2) ; return c; }()
 
RCP< const Basici3 = []() { static const RCP<const Basic > c = integer(3) ; return c; }()
 
RCP< const Basici5 = []() { static const RCP<const Basic > c = integer(5) ; return c; }()
 
RCP< const Basicim2 = []() { static const RCP<const Basic > c = integer(-2) ; return c; }()
 
RCP< const Basicim3 = []() { static const RCP<const Basic > c = integer(-3) ; return c; }()
 
RCP< const Basicim5 = []() { static const RCP<const Basic > c = integer(-5) ; return c; }()
 
RCP< const Basicsq3 = []() { static const RCP<const Basic > c = sqrt_(i3) ; return c; }()
 
RCP< const Basicsq2 = []() { static const RCP<const Basic > c = sqrt_(i2) ; return c; }()
 
RCP< const Basicsq5 = []() { static const RCP<const Basic > c = sqrt_(i5) ; return c; }()
 
RCP< const BasicC0 = []() { static const RCP<const Basic > c = div(sub(sq3, one), mul(i2, sq2)) ; return c; }()
 
RCP< const BasicC1 = []() { static const RCP<const Basic > c = div(one, i2) ; return c; }()
 
RCP< const BasicC2 = []() { static const RCP<const Basic > c = div(sq2, i2) ; return c; }()
 
RCP< const BasicC3 = []() { static const RCP<const Basic > c = div(sq3, i2) ; return c; }()
 
RCP< const BasicC4 = []() { static const RCP<const Basic > c = div(add(sq3, one), mul(i2, sq2)) ; return c; }()
 
RCP< const BasicC5 = []() { static const RCP<const Basic > c = div(sqrt_(sub(i5, sqrt_(i5))), integer(8)) ; return c; }()
 
RCP< const BasicC6 = []() { static const RCP<const Basic > c = div(sub(sqrt_(i5), one), integer(4)) ; return c; }()
 
RCP< const BasicmC0 = []() { static const RCP<const Basic > c = mul(minus_one, C0) ; return c; }()
 
RCP< const BasicmC1 = []() { static const RCP<const Basic > c = mul(minus_one, C1) ; return c; }()
 
RCP< const BasicmC2 = []() { static const RCP<const Basic > c = mul(minus_one, C2) ; return c; }()
 
RCP< const BasicmC3 = []() { static const RCP<const Basic > c = mul(minus_one, C3) ; return c; }()
 
RCP< const BasicmC4 = []() { static const RCP<const Basic > c = mul(minus_one, C4) ; return c; }()
 
RCP< const BasicmC5 = []() { static const RCP<const Basic > c = mul(minus_one, C5) ; return c; }()
 
RCP< const BasicmC6 = []() { static const RCP<const Basic > c = mul(minus_one, C6) ; return c; }()
 
RCP< const BooleanAtomboolTrue = []() { static const RCP<const BooleanAtom> c = make_rcp<BooleanAtom>( true ); return c; }()
 
RCP< const BooleanAtomboolFalse = []() { static const RCP<const BooleanAtom> c = make_rcp<BooleanAtom>( false ); return c; }()
 

Detailed Description

Main namespace for SymEngine package.

Typedef Documentation

◆ enable_if_t

template<bool B, class T = void>
using SymEngine::enable_if_t = typedef typename std::enable_if<B, T>::type

Definition at line 103 of file dict.h.

◆ fn

typedef std::function<double(const Basic &)> SymEngine::fn

Definition at line 451 of file eval_double.cpp.

◆ hash_t

typedef uint64_t SymEngine::hash_t

Definition at line 32 of file dict.h.

◆ integer_class

typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off> SymEngine::integer_class

Definition at line 54 of file mp_class.h.

◆ map_basic_basic

Definition at line 57 of file dict.h.

◆ map_basic_num

typedef std::map<RCP<const Basic>, RCP<const Number>, RCPBasicKeyLess> SymEngine::map_basic_num

Definition at line 55 of file dict.h.

◆ map_int_Expr

Definition at line 62 of file dict.h.

◆ map_integer_uint

Definition at line 59 of file dict.h.

◆ map_uint_mpq

typedef std::map<unsigned, rational_class> SymEngine::map_uint_mpq

Definition at line 61 of file dict.h.

◆ map_uint_mpz

typedef std::map<unsigned, integer_class> SymEngine::map_uint_mpz

Definition at line 60 of file dict.h.

◆ map_vec_mpz

typedef std::map<vec_uint, integer_class> SymEngine::map_vec_mpz

Definition at line 53 of file dict.h.

◆ map_vec_uint

typedef std::map<vec_uint, unsigned long long int> SymEngine::map_vec_uint

Definition at line 52 of file dict.h.

◆ multiset_basic

Definition at line 51 of file dict.h.

◆ permutelist

Definition at line 99 of file matrix.h.

◆ PiecewiseVec

typedef std::vector<std::pair<RCP<const Basic>, RCP<const Boolean> > > SymEngine::PiecewiseVec

Definition at line 78 of file logic.h.

◆ rational_class

typedef boost::multiprecision::number< boost::multiprecision::cpp_rational_backend, boost::multiprecision::et_off> SymEngine::rational_class

Definition at line 57 of file mp_class.h.

◆ set_basic

Definition at line 50 of file dict.h.

◆ set_boolean

Definition at line 14 of file logic.h.

◆ set_set

Definition at line 24 of file sets.h.

◆ TwoArgFunction

Definition at line 141 of file functions.h.

◆ umap_basic_basic

Definition at line 40 of file dict.h.

◆ umap_basic_bool

Definition at line 11 of file assumptions.h.

◆ umap_basic_num

Definition at line 35 of file dict.h.

◆ umap_basic_uint

Definition at line 65 of file dict.h.

◆ umap_int_basic

Definition at line 37 of file dict.h.

◆ umap_short_basic

Definition at line 36 of file dict.h.

◆ umap_uvec_mpz

Definition at line 74 of file dict.h.

◆ umap_vec_expr

◆ umap_vec_mpz

Definition at line 76 of file dict.h.

◆ uset_basic

Definition at line 42 of file dict.h.

◆ vec_basic

typedef std::vector<RCP<const Basic> > SymEngine::vec_basic

Definition at line 45 of file dict.h.

◆ vec_boolean

Definition at line 15 of file logic.h.

◆ vec_int

Definition at line 44 of file dict.h.

◆ vec_integer

Definition at line 46 of file dict.h.

◆ vec_integer_class

typedef std::vector<integer_class> SymEngine::vec_integer_class

Definition at line 48 of file dict.h.

◆ vec_pair

typedef std::vector<std::pair<RCP<const Basic>, RCP<const Basic> > > SymEngine::vec_pair

Definition at line 66 of file dict.h.

◆ vec_sym

typedef std::vector<RCP<const Symbol> > SymEngine::vec_sym

Definition at line 49 of file dict.h.

◆ vec_uint

typedef std::vector<unsigned int> SymEngine::vec_uint

Definition at line 47 of file dict.h.

Enumeration Type Documentation

◆ EvalfDomain

enum class SymEngine::EvalfDomain
strong

Definition at line 28 of file eval.h.

28 {
29 Complex = 0,
30 Real = 1,
31 Symbolic = 2,
32};
Complex Class.
Definition: complex.h:33

◆ PrecedenceEnum

enum class SymEngine::PrecedenceEnum
strong

Definition at line 13 of file strprinter.h.

13{ Relational, Add, Mul, Pow, Atom };
The base class for representing addition in symbolic expressions.
Definition: add.h:27

◆ tribool

enum class SymEngine::tribool
strong

Definition at line 7 of file tribool.h.

7{ indeterminate = -1, trifalse = 0, tritrue = 1 };

◆ 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

◆ _basic_to_mpoly() [1/2]

template<typename P >
enable_if_t< std::is_same< MIntPoly, P >::value, typename P::container_type > SymEngine::_basic_to_mpoly ( const RCP< const Basic > &  basic,
const set_basic gens 
)

Definition at line 527 of file basic_conversions.h.

528{
529 BasicToMIntPoly v(gens);
530 return v.apply(*basic);
531}

◆ _basic_to_mpoly() [2/2]

template<typename P >
enable_if_t< std::is_same< MExprPoly, P >::value, typename P::container_type > SymEngine::_basic_to_mpoly ( const RCP< const Basic > &  basic,
const set_basic gens 
)

Definition at line 535 of file basic_conversions.h.

536{
537 BasicToMExprPoly v(gens);
538 return v.apply(*basic);
539}

◆ _basic_to_upoly() [1/3]

template<typename T , typename P >
enable_if_t< std::is_same< T, UExprDict >::value, T > SymEngine::_basic_to_upoly ( const RCP< const Basic > &  basic,
const RCP< const Basic > &  gen 
)

Definition at line 270 of file basic_conversions.h.

271{
272 BasicToUExprPoly v(gen);
273 return v.apply(*basic);
274}

◆ _basic_to_upoly() [2/3]

template<typename T , typename P >
enable_if_t< std::is_base_of< UIntPolyBase< T, P >, P >::value, T > SymEngine::_basic_to_upoly ( const RCP< const Basic > &  basic,
const RCP< const Basic > &  gen 
)

Definition at line 278 of file basic_conversions.h.

279{
280 BasicToUIntPoly<P> v(gen);
281 return v.apply(*basic);
282}

◆ _basic_to_upoly() [3/3]

template<typename T , typename P >
enable_if_t< std::is_base_of< URatPolyBase< T, P >, P >::value, T > SymEngine::_basic_to_upoly ( const RCP< const Basic > &  basic,
const RCP< const Basic > &  gen 
)

Definition at line 286 of file basic_conversions.h.

287{
288 BasicToURatPoly<P> v(gen);
289 return v.apply(*basic);
290}

◆ _find_gens_poly()

umap_basic_num SymEngine::_find_gens_poly ( const RCP< const Basic > &  x)

Definition at line 165 of file basic_conversions.cpp.

166{
168 return v.apply(*x);
169}

◆ _find_gens_poly_pow()

umap_basic_num SymEngine::_find_gens_poly_pow ( const RCP< const Basic > &  x,
const RCP< const Basic > &  base 
)

Definition at line 171 of file basic_conversions.cpp.

173{
175 return v.apply(*x, base);
176}

◆ _imulnum()

void SymEngine::_imulnum ( const Ptr< RCP< const Number > > &  self,
const RCP< const Number > &  other 
)
inline

Definition at line 16 of file expand.cpp.

18{
19 *self = _mulnum(*self, other);
20}

◆ _is_nthroot_mod_prime_power()

bool SymEngine::_is_nthroot_mod_prime_power ( const integer_class &  a,
const integer_class &  n,
const integer_class &  p,
const unsigned  k 
)

Definition at line 1308 of file ntheory.cpp.

1310{
1311 integer_class pk;
1312 if (a % p != 0) {
1313 if (p == 2) {
1314 integer_class t;
1315 unsigned c = numeric_cast<unsigned>(mp_scan1(n));
1316
1317 // Handle special cases of k = 1 and k = 2.
1318 if (k == 1) {
1319 return true;
1320 }
1321 if (k == 2) {
1322 if (c > 0 and a % 4 == 3) {
1323 return false;
1324 }
1325 return true;
1326 }
1327 if (c >= k - 2) {
1328 c = k - 2; // Since x**(2**c) == x**(2**(k - 2)) mod 2**k, let c
1329 // = k - 2.
1330 }
1331 if (c == 0) {
1332 // x**r == a mod 2**k and x**2**(k - 2) == 1 mod 2**k, implies
1333 // x**(r * s) == x == a**s mod 2**k.
1334 return true;
1335 }
1336
1337 // First, solve for y**2**c == a mod 2**k where y == x**r
1338 t = integer_class(1) << (c + 2);
1339 mp_fdiv_r(t, a, t);
1340 // Check for a == y**2**c == 1 mod 2**(c + 2).
1341 if (t != 1)
1342 return false;
1343 return true;
1344 } else {
1345 return _is_nthroot_mod1(a, n, p, k);
1346 }
1347 } else {
1348 integer_class _a;
1349 mp_pow_ui(pk, p, k);
1350 _a = a % pk;
1351 integer_class pm;
1352 if (_a == 0) {
1353 return true;
1354 } else {
1355 unsigned r = 1;
1356 mp_divexact(_a, _a, p);
1357 while (_a % p == 0) {
1358 mp_divexact(_a, _a, p);
1359 ++r;
1360 }
1361 if (r < n or r % n != 0
1362 or not _is_nthroot_mod_prime_power(_a, n, p, k - r)) {
1363 return false;
1364 }
1365 return true;
1366 }
1367 }
1368 return true;
1369}

◆ _mulnum()

RCP< const Number > SymEngine::_mulnum ( const RCP< const Number > &  x,
const RCP< const Number > &  y 
)
inline

Definition at line 6 of file expand.cpp.

8{
9 if (eq(*x, *one))
10 return y;
11 if (eq(*y, *one))
12 return x;
13 return x->mul(*y);
14}
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ _print_sign()

template<typename T >
char SymEngine::_print_sign ( const T &  i)

Definition at line 659 of file strprinter.cpp.

660{
661 if (i < 0) {
662 return '-';
663 } else {
664 return '+';
665 }
666}

◆ _str()

static std::string SymEngine::_str ( const Basic a)
static

Definition at line 87 of file cwrapper.cpp.

88{
89 return a.__str__();
90}
std::string __str__() const
Definition: basic.cpp:46

◆ abs()

RCP< const Basic > SymEngine::abs ( const RCP< const Basic > &  arg)

Canonicalize Abs:

Definition at line 3492 of file functions.cpp.

3493{
3494 if (is_a<Integer>(*arg)) {
3495 RCP<const Integer> arg_ = rcp_static_cast<const Integer>(arg);
3496 if (arg_->is_negative()) {
3497 return arg_->neg();
3498 } else {
3499 return arg_;
3500 }
3501 } else if (is_a<Rational>(*arg)) {
3502 RCP<const Rational> arg_ = rcp_static_cast<const Rational>(arg);
3503 if (arg_->is_negative()) {
3504 return arg_->neg();
3505 } else {
3506 return arg_;
3507 }
3508 } else if (is_a<Complex>(*arg)) {
3509 RCP<const Complex> arg_ = rcp_static_cast<const Complex>(arg);
3510 return sqrt(Rational::from_mpq(arg_->real_ * arg_->real_
3511 + arg_->imaginary_ * arg_->imaginary_));
3512 } else if (is_a_Number(*arg)
3513 and not down_cast<const Number &>(*arg).is_exact()) {
3514 return down_cast<const Number &>(*arg).get_eval().abs(*arg);
3515 }
3516 if (is_a<Abs>(*arg)) {
3517 return arg;
3518 }
3519
3520 RCP<const Basic> d;
3521 handle_minus(arg, outArg(d));
3522 return make_rcp<const Abs>(d);
3523}
T sqrt(T... args)

◆ acos()

RCP< const Basic > SymEngine::acos ( const RCP< const Basic > &  arg)

Canonicalize ACos:

Definition at line 1402 of file functions.cpp.

1403{
1404 if (eq(*arg, *zero))
1405 return div(pi, i2);
1406 else if (eq(*arg, *one))
1407 return zero;
1408 else if (eq(*arg, *minus_one))
1409 return pi;
1410 else if (is_a_Number(*arg)
1411 and not down_cast<const Number &>(*arg).is_exact()) {
1412 return down_cast<const Number &>(*arg).get_eval().acos(*arg);
1413 }
1414
1415 RCP<const Basic> index;
1416 bool b = inverse_lookup(inverse_cst(), arg, outArg(index));
1417 if (b) {
1418 return sub(div(pi, i2), div(pi, index));
1419 } else {
1420 return make_rcp<const ACos>(arg);
1421 }
1422}

◆ acosh()

RCP< const Basic > SymEngine::acosh ( const RCP< const Basic > &  arg)

Canonicalize ACosh:

Definition at line 2461 of file functions.cpp.

2462{
2463 // TODO: Lookup into a cst table once complex is implemented
2464 if (eq(*arg, *one))
2465 return zero;
2466 if (is_a_Number(*arg) and not down_cast<const Number &>(*arg).is_exact()) {
2467 return down_cast<const Number &>(*arg).get_eval().acosh(*arg);
2468 }
2469 return make_rcp<const ACosh>(arg);
2470}

◆ acot()

RCP< const Basic > SymEngine::acot ( const RCP< const Basic > &  arg)

Canonicalize ACot:

Definition at line 1566 of file functions.cpp.

1567{
1568 if (eq(*arg, *zero))
1569 return div(pi, i2);
1570 else if (eq(*arg, *one))
1571 return div(pi, mul(i2, i2));
1572 else if (eq(*arg, *minus_one))
1573 return mul(i3, div(pi, mul(i2, i2)));
1574 else if (is_a_Number(*arg)
1575 and not down_cast<const Number &>(*arg).is_exact()) {
1576 return down_cast<const Number &>(*arg).get_eval().acot(*arg);
1577 }
1578
1579 RCP<const Basic> index;
1580 bool b = inverse_lookup(inverse_tct(), arg, outArg(index));
1581 if (b) {
1582 return sub(div(pi, i2), div(pi, index));
1583 } else {
1584 return make_rcp<const ACot>(arg);
1585 }
1586}
RCP< const Basic > mul(const RCP< const Basic > &a, const RCP< const Basic > &b)
Multiplication.
Definition: mul.cpp:352

◆ acoth()

RCP< const Basic > SymEngine::acoth ( const RCP< const Basic > &  arg)

Canonicalize ACoth:

Definition at line 2534 of file functions.cpp.

2535{
2536 if (is_a_Number(*arg)) {
2537 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2538 if (not _arg->is_exact()) {
2539 return _arg->get_eval().acoth(*_arg);
2540 } else if (_arg->is_negative()) {
2541 return neg(acoth(zero->sub(*_arg)));
2542 }
2543 }
2544 RCP<const Basic> d;
2545 bool b = handle_minus(arg, outArg(d));
2546 if (b) {
2547 return neg(acoth(d));
2548 }
2549 return make_rcp<const ACoth>(d);
2550}
RCP< const Basic > acoth(const RCP< const Basic > &arg)
Canonicalize ACoth:
Definition: functions.cpp:2534
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:443

◆ acsc()

RCP< const Basic > SymEngine::acsc ( const RCP< const Basic > &  arg)

Canonicalize ACsc:

Definition at line 1484 of file functions.cpp.

1485{
1486 if (eq(*arg, *one))
1487 return div(pi, i2);
1488 else if (eq(*arg, *minus_one))
1489 return div(pi, im2);
1490 else if (is_a_Number(*arg)
1491 and not down_cast<const Number &>(*arg).is_exact()) {
1492 return down_cast<const Number &>(*arg).get_eval().acsc(*arg);
1493 }
1494
1495 RCP<const Basic> index;
1496 bool b = inverse_lookup(inverse_cst(), div(one, arg), outArg(index));
1497 if (b) {
1498 return div(pi, index);
1499 } else {
1500 return make_rcp<const ACsc>(arg);
1501 }
1502}

◆ acsch()

RCP< const Basic > SymEngine::acsch ( const RCP< const Basic > &  arg)

Canonicalize ACsch:

Definition at line 2422 of file functions.cpp.

2423{
2424 if (eq(*arg, *one))
2425 return log(add(one, sq2));
2426 if (eq(*arg, *minus_one))
2427 return log(sub(sq2, one));
2428
2429 if (is_a_Number(*arg)) {
2430 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2431 if (not _arg->is_exact()) {
2432 return _arg->get_eval().acsch(*_arg);
2433 }
2434 }
2435
2436 RCP<const Basic> d;
2437 bool b = handle_minus(arg, outArg(d));
2438 if (b) {
2439 return neg(acsch(d));
2440 }
2441 return make_rcp<const ACsch>(d);
2442}
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 > acsch(const RCP< const Basic > &arg)
Canonicalize ACsch:
Definition: functions.cpp:2422
RCP< const Basic > add(const RCP< const Basic > &a, const RCP< const Basic > &b)
Adds two objects (safely).
Definition: add.cpp:425

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

◆ 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}

◆ add_dense_dense()

void SymEngine::add_dense_dense ( const DenseMatrix A,
const DenseMatrix B,
DenseMatrix C 
)

Definition at line 651 of file dense_matrix.cpp.

652{
653 SYMENGINE_ASSERT(A.row_ == B.row_ and A.col_ == B.col_ and A.row_ == C.row_
654 and A.col_ == C.col_);
655
656 unsigned row = A.row_, col = A.col_;
657
658 for (unsigned i = 0; i < row; i++) {
659 for (unsigned j = 0; j < col; j++) {
660 C.m_[i * col + j] = add(A.m_[i * col + j], B.m_[i * col + j]);
661 }
662 }
663}

◆ add_dense_scalar()

void SymEngine::add_dense_scalar ( const DenseMatrix A,
const RCP< const Basic > &  k,
DenseMatrix B 
)

Definition at line 665 of file dense_matrix.cpp.

667{
668 SYMENGINE_ASSERT(A.row_ == B.row_ and A.col_ == B.col_);
669
670 unsigned row = A.row_, col = A.col_;
671
672 for (unsigned i = 0; i < row; i++) {
673 for (unsigned j = 0; j < col; j++) {
674 B.m_[i * col + j] = add(A.m_[i * col + j], k);
675 }
676 }
677}

◆ add_mpoly()

template<typename Poly >
RCP< const Poly > SymEngine::add_mpoly ( const Poly &  a,
const Poly &  b 
)

Definition at line 492 of file msymenginepoly.h.

493{
494 typename Poly::container_type x, y;
495 set_basic s = get_translated_container(x, y, a, b);
496 x += y;
497 return Poly::from_container(s, std::move(x));
498}

◆ add_to_sorted_vec()

void SymEngine::add_to_sorted_vec ( std::vector< unsigned > &  vec,
unsigned  number 
)

Definition at line 194 of file cse.cpp.

195{
196 if (std::find(vec.begin(), vec.end(), number) == vec.end()) {
197 // Add number if not found
198 vec.insert(std::upper_bound(vec.begin(), vec.end(), number), number);
199 }
200}
T begin(T... args)
T insert(T... args)
T upper_bound(T... args)

◆ add_upoly()

template<typename Poly >
RCP< const Poly > SymEngine::add_upoly ( const Poly &  a,
const Poly &  b 
)

Definition at line 672 of file upolybase.h.

673{
674 if (!(a.get_var()->__eq__(*b.get_var())))
675 throw SymEngineException("Error: variables must agree.");
676
677 auto dict = a.get_poly();
678 dict += b.get_poly();
679 return Poly::from_container(a.get_var(), std::move(dict));
680}

◆ addnum()

RCP< const Number > SymEngine::addnum ( const RCP< const Number > &  self,
const RCP< const Number > &  other 
)
inline

Add self and other

Definition at line 81 of file number.h.

83{
84 return self->add(*other);
85}

◆ and_or()

template<typename caller >
RCP< const Boolean > SymEngine::and_or ( const set_boolean s,
const bool &  op_x_notx 
)

Definition at line 465 of file logic.cpp.

466{
467 set_boolean args;
468 for (auto &a : s) {
469 if (is_a<BooleanAtom>(*a)) {
470 auto val = down_cast<const BooleanAtom &>(*a).get_val();
471 if (val == op_x_notx)
472 return boolean(op_x_notx);
473 else
474 continue;
475 }
476 if (is_a<caller>(*a)) {
477 const caller &to_insert = down_cast<const caller &>(*a);
478 auto container = to_insert.get_container();
479 args.insert(container.begin(), container.end());
480 continue;
481 }
482 args.insert(a);
483 }
484 for (auto &a : args) {
485 if (args.find(logical_not(a)) != args.end())
486 return boolean(op_x_notx);
487 }
488 if (not op_x_notx) {
489 for (auto it = args.begin(); it != args.end(); it++) {
490 if (is_a<Contains>(**it)
491 and is_a<Symbol>(*down_cast<const Contains &>(**it).get_expr())
492 and is_a<FiniteSet>(
493 *down_cast<const Contains &>(**it).get_set())) {
494 auto sym = down_cast<const Contains &>(**it).get_expr();
495 // iterate through args and check for the condition that
496 // defines the domain of sym.
497 // Simplify if that set is a FiniteSet.
498 set_basic present;
499 auto fset = down_cast<const FiniteSet &>(
500 *down_cast<const Contains &>(**it).get_set())
501 .get_container();
502 // If there exists atleast one number/constant, then only we can
503 // simplify.
504 bool check = false;
505 for (const auto &elem : fset) {
506 if (is_a_Number(*elem) or is_a<Constant>(*elem)) {
507 check = true;
508 break;
509 }
510 }
511 if (!check)
512 break;
513 auto restCont = args;
514 restCont.erase(*it);
515 auto restCond = logical_and(restCont);
516 map_basic_basic d;
517 bool symexists = false;
518 for (const auto &fselement : fset) {
519 d[sym] = fselement;
520 auto contain = restCond->subs(d);
521 if (eq(*contain, *boolean(true))) {
522 present.insert(fselement);
523 } else if (not eq(*contain, *boolean(false))) {
524 present.insert(fselement);
525 symexists = true;
526 }
527 d.clear();
528 }
529 if (not symexists) {
530 // if there are no symbols, then this reduces to a
531 // Contains(sym,finiteset())
532 return finiteset(present)->contains(sym);
533 } else if (present.size() != fset.size()) {
534 restCond = logical_and(
535 {finiteset(present)->contains(sym), restCond});
536 return restCond;
537 } else {
538 // if present is same as fset, then return object of type
539 // `And`.
540 break;
541 }
542 }
543 }
544 }
545 if (args.size() == 1)
546 return *(args.begin());
547 else if (args.size() == 0)
548 return boolean(not op_x_notx);
549 return make_rcp<const caller>(args);
550}
RCP< const Set > finiteset(const set_basic &container)
Definition: sets.h:602

◆ and_tribool()

tribool SymEngine::and_tribool ( tribool  a,
tribool  b 
)
inline

Definition at line 29 of file tribool.h.

30{
31 if (!(static_cast<unsigned>(a) & static_cast<unsigned>(b))) {
32 return tribool::trifalse;
33 } else {
34 return static_cast<tribool>(static_cast<unsigned>(a)
35 | static_cast<unsigned>(b));
36 }
37}

◆ andwk_tribool()

tribool SymEngine::andwk_tribool ( tribool  a,
tribool  b 
)
inline

Definition at line 61 of file tribool.h.

62{
63 if (is_indeterminate(a) || is_indeterminate(b)) {
64 return tribool::indeterminate;
65 } else {
66 return static_cast<tribool>(static_cast<unsigned>(a)
67 && static_cast<unsigned>(b));
68 }
69}

◆ as_numer_denom()

void SymEngine::as_numer_denom ( const RCP< const Basic > &  x,
const Ptr< RCP< const Basic > > &  numer,
const Ptr< RCP< const Basic > > &  denom 
)

Definition at line 133 of file numer_denom.cpp.

136{
137 NumerDenomVisitor v(numer, denom);
138 v.apply(*x);
139}

◆ as_real_imag()

void SymEngine::as_real_imag ( const RCP< const Basic > &  x,
const Ptr< RCP< const Basic > > &  real,
const Ptr< RCP< const Basic > > &  imag 
)

Definition at line 282 of file as_real_imag.cpp.

284{
285 RealImagVisitor v(real, imag);
286 v.apply(*x);
287}

◆ ascii_art()

std::string SymEngine::ascii_art ( )

Definition at line 18 of file strprinter.cpp.

19{
20 std::string a = " _____ _____ _ \n"
21 "| __|_ _ _____| __|___ ___|_|___ ___ \n"
22 "|__ | | | | __| | . | | | -_|\n"
23 "|_____|_ |_|_|_|_____|_|_|_ |_|_|_|___|\n"
24 " |___| |___| \n";
25 return a;
26}

◆ asec()

RCP< const Basic > SymEngine::asec ( const RCP< const Basic > &  arg)

Canonicalize ASec:

Definition at line 1444 of file functions.cpp.

1445{
1446 if (eq(*arg, *one))
1447 return zero;
1448 else if (eq(*arg, *minus_one))
1449 return pi;
1450 else if (is_a_Number(*arg)
1451 and not down_cast<const Number &>(*arg).is_exact()) {
1452 return down_cast<const Number &>(*arg).get_eval().asec(*arg);
1453 }
1454
1455 RCP<const Basic> index;
1456 bool b = inverse_lookup(inverse_cst(), div(one, arg), outArg(index));
1457 if (b) {
1458 return sub(div(pi, i2), div(pi, index));
1459 } else {
1460 return make_rcp<const ASec>(arg);
1461 }
1462}

◆ asech()

RCP< const Basic > SymEngine::asech ( const RCP< const Basic > &  arg)

Canonicalize ASech:

Definition at line 2571 of file functions.cpp.

2572{
2573 // TODO: Lookup into a cst table once complex is implemented
2574 if (eq(*arg, *one))
2575 return zero;
2576 if (eq(*arg, *zero))
2577 return Inf;
2578 if (is_a_Number(*arg)) {
2579 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2580 if (not _arg->is_exact()) {
2581 return _arg->get_eval().asech(*_arg);
2582 }
2583 }
2584 return make_rcp<const ASech>(arg);
2585}

◆ asin()

RCP< const Basic > SymEngine::asin ( const RCP< const Basic > &  arg)

Canonicalize ASin:

Definition at line 1360 of file functions.cpp.

1361{
1362 if (eq(*arg, *zero))
1363 return zero;
1364 else if (eq(*arg, *one))
1365 return div(pi, i2);
1366 else if (eq(*arg, *minus_one))
1367 return mul(minus_one, div(pi, i2));
1368 else if (is_a_Number(*arg)
1369 and not down_cast<const Number &>(*arg).is_exact()) {
1370 return down_cast<const Number &>(*arg).get_eval().asin(*arg);
1371 }
1372
1373 RCP<const Basic> index;
1374 bool b = inverse_lookup(inverse_cst(), arg, outArg(index));
1375 if (b) {
1376 return div(pi, index);
1377 } else {
1378 return make_rcp<const ASin>(arg);
1379 }
1380}

◆ asinh()

RCP< const Basic > SymEngine::asinh ( const RCP< const Basic > &  arg)

Canonicalize ASinh:

Definition at line 2376 of file functions.cpp.

2377{
2378 if (eq(*arg, *zero))
2379 return zero;
2380 if (eq(*arg, *one))
2381 return log(add(one, sq2));
2382 if (eq(*arg, *minus_one))
2383 return log(sub(sq2, one));
2384 if (is_a_Number(*arg)) {
2385 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2386 if (not _arg->is_exact()) {
2387 return _arg->get_eval().asinh(*_arg);
2388 } else if (_arg->is_negative()) {
2389 return neg(asinh(zero->sub(*_arg)));
2390 }
2391 }
2392 RCP<const Basic> d;
2393 bool b = handle_minus(arg, outArg(d));
2394 if (b) {
2395 return neg(asinh(d));
2396 }
2397 return make_rcp<const ASinh>(d);
2398}
T asinh(T... args)

◆ atan()

RCP< const Basic > SymEngine::atan ( const RCP< const Basic > &  arg)

Canonicalize ATan:

Definition at line 1524 of file functions.cpp.

1525{
1526 if (eq(*arg, *zero))
1527 return zero;
1528 else if (eq(*arg, *one))
1529 return div(pi, mul(i2, i2));
1530 else if (eq(*arg, *minus_one))
1531 return mul(minus_one, div(pi, mul(i2, i2)));
1532 else if (is_a_Number(*arg)
1533 and not down_cast<const Number &>(*arg).is_exact()) {
1534 return down_cast<const Number &>(*arg).get_eval().atan(*arg);
1535 }
1536
1537 RCP<const Basic> index;
1538 bool b = inverse_lookup(inverse_tct(), arg, outArg(index));
1539 if (b) {
1540 return div(pi, index);
1541 } else {
1542 return make_rcp<const ATan>(arg);
1543 }
1544}

◆ atan2()

RCP< const Basic > SymEngine::atan2 ( const RCP< const Basic > &  num,
const RCP< const Basic > &  den 
)

Canonicalize ATan2:

Definition at line 1614 of file functions.cpp.

1615{
1616 if (eq(*num, *zero)) {
1617 if (is_a_Number(*den)) {
1618 RCP<const Number> den_new = rcp_static_cast<const Number>(den);
1619 if (den_new->is_negative())
1620 return pi;
1621 else if (den_new->is_positive())
1622 return zero;
1623 else {
1624 return Nan;
1625 }
1626 }
1627 } else if (eq(*den, *zero)) {
1628 if (is_a_Number(*num)) {
1629 RCP<const Number> num_new = rcp_static_cast<const Number>(num);
1630 if (num_new->is_negative())
1631 return div(pi, im2);
1632 else
1633 return div(pi, i2);
1634 }
1635 }
1636 RCP<const Basic> index;
1637 bool b = inverse_lookup(inverse_tct(), div(num, den), outArg(index));
1638 if (b) {
1639 // Ideally the answer should depend on the signs of `num` and `den`
1640 // Currently is_positive() and is_negative() is not implemented for
1641 // types other than `Number`
1642 // Hence this will give exact answers in case when num and den are
1643 // numbers in SymEngine sense and when num and den are positive.
1644 // for the remaining cases in which we just return the value from
1645 // the lookup table.
1646 // TODO: update once is_positive() and is_negative() is implemented
1647 // in `Basic`
1648 if (is_a_Number(*den) and is_a_Number(*num)) {
1649 RCP<const Number> den_new = rcp_static_cast<const Number>(den);
1650 RCP<const Number> num_new = rcp_static_cast<const Number>(num);
1651
1652 if (den_new->is_positive()) {
1653 return div(pi, index);
1654 } else if (den_new->is_negative()) {
1655 if (num_new->is_negative()) {
1656 return sub(div(pi, index), pi);
1657 } else {
1658 return add(div(pi, index), pi);
1659 }
1660 } else {
1661 return div(pi, index);
1662 }
1663 } else {
1664 return div(pi, index);
1665 }
1666 } else {
1667 return make_rcp<const ATan2>(num, den);
1668 }
1669}
T div(T... args)
bool inverse_lookup(const umap_basic_basic &d, const RCP< const Basic > &t, const Ptr< RCP< const Basic > > &index)
Definition: functions.cpp:480

◆ atanh()

RCP< const Basic > SymEngine::atanh ( const RCP< const Basic > &  arg)

Canonicalize ATanh:

Definition at line 2494 of file functions.cpp.

2495{
2496 if (eq(*arg, *zero))
2497 return zero;
2498 if (is_a_Number(*arg)) {
2499 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2500 if (not _arg->is_exact()) {
2501 return _arg->get_eval().atanh(*_arg);
2502 } else if (_arg->is_negative()) {
2503 return neg(atanh(zero->sub(*_arg)));
2504 }
2505 }
2506 RCP<const Basic> d;
2507 bool b = handle_minus(arg, outArg(d));
2508 if (b) {
2509 return neg(atanh(d));
2510 }
2511 return make_rcp<const ATanh>(d);
2512}
T atanh(T... args)

◆ atoms()

template<typename... Args>
set_basic SymEngine::atoms ( const Basic b)
inline

Definition at line 313 of file visitor.h.

314{
315 AtomsVisitor<Args...> visitor;
316 return visitor.apply(b);
317};

◆ back_substitution()

void SymEngine::back_substitution ( const DenseMatrix U,
const DenseMatrix b,
DenseMatrix x 
)

Definition at line 1145 of file dense_matrix.cpp.

1147{
1148 SYMENGINE_ASSERT(U.row_ == U.col_);
1149 SYMENGINE_ASSERT(b.row_ == U.row_);
1150 SYMENGINE_ASSERT(x.row_ == U.col_ and x.col_ == b.col_);
1151
1152 const unsigned col = U.col_;
1153 const unsigned sys = b.col_;
1154 x.m_ = b.m_;
1155
1156 for (unsigned k = 0; k < sys; k++) {
1157 for (int i = col - 1; i >= 0; i--) {
1158 for (unsigned j = i + 1; j < col; j++)
1159 x.m_[i * sys + k]
1160 = sub(x.m_[i * sys + k],
1161 mul(U.m_[i * col + j], x.m_[j * sys + k]));
1162 x.m_[i * sys + k] = div(x.m_[i * sys + k], U.m_[i * col + i]);
1163 }
1164 }
1165}

◆ berkowitz()

void SymEngine::berkowitz ( const DenseMatrix A,
std::vector< DenseMatrix > &  polys 
)

Definition at line 1755 of file dense_matrix.cpp.

1756{
1757 SYMENGINE_ASSERT(A.row_ == A.col_);
1758
1759 unsigned col = A.col_;
1760 unsigned i, k, l, m;
1761
1763 std::vector<DenseMatrix> transforms;
1765
1766 for (unsigned n = col; n > 1; n--) {
1767 items.clear();
1768 k = n - 1;
1769 DenseMatrix T = DenseMatrix(n + 1, n);
1770 DenseMatrix C = DenseMatrix(k, 1);
1771
1772 // Initialize T and C
1773 for (i = 0; i < n * (n + 1); i++)
1774 T.m_[i] = zero;
1775 for (i = 0; i < k; i++)
1776 C.m_[i] = A.m_[i * col + k];
1777 items.push_back(C);
1778
1779 for (i = 0; i < n - 2; i++) {
1780 DenseMatrix B = DenseMatrix(k, 1);
1781 for (l = 0; l < k; l++) {
1782 B.m_[l] = zero;
1783 for (m = 0; m < k; m++)
1784 B.m_[l]
1785 = add(B.m_[l], mul(A.m_[l * col + m], items[i].m_[m]));
1786 }
1787 items.push_back(B);
1788 }
1789
1790 items_.clear();
1791 for (i = 0; i < n - 1; i++) {
1792 RCP<const Basic> element = zero;
1793 for (l = 0; l < k; l++)
1794 element = add(element, mul(A.m_[k * col + l], items[i].m_[l]));
1795 items_.push_back(mul(minus_one, element));
1796 }
1797 items_.insert(items_.begin(), mul(minus_one, A.m_[k * col + k]));
1798 items_.insert(items_.begin(), one);
1799
1800 for (i = 0; i < n; i++) {
1801 for (l = 0; l < n - i + 1; l++)
1802 T.m_[(i + l) * n + i] = items_[l];
1803 }
1804
1805 transforms.push_back(T);
1806 }
1807
1808 polys.push_back(DenseMatrix(2, 1, {one, mul(A.m_[0], minus_one)}));
1809
1810 for (i = 0; i < col - 1; i++) {
1811 unsigned t_row = transforms[col - 2 - i].nrows();
1812 unsigned t_col = transforms[col - 2 - i].ncols();
1813 DenseMatrix B = DenseMatrix(t_row, 1);
1814
1815 for (l = 0; l < t_row; l++) {
1816 B.m_[l] = zero;
1817 for (m = 0; m < t_col; m++) {
1818 B.m_[l] = add(B.m_[l],
1819 mul(transforms[col - 2 - i].m_[l * t_col + m],
1820 polys[i].m_[m]));
1821 B.m_[l] = expand(B.m_[l]);
1822 }
1823 }
1824 polys.push_back(B);
1825 }
1826}
T clear(T... args)
RCP< const Basic > expand(const RCP< const Basic > &self, bool deep=true)
Expands self
Definition: expand.cpp:369
T push_back(T... args)

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

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

◆ beta()

RCP< const Basic > SymEngine::beta ( const RCP< const Basic > &  x,
const RCP< const Basic > &  y 
)

Canonicalize Beta:

Definition at line 3283 of file functions.cpp.

3284{
3285 // Only special values are being evaluated
3286 if (eq(*add(x, y), *one)) {
3287 return ComplexInf;
3288 }
3289
3290 if (is_a<Integer>(*x)) {
3291 RCP<const Integer> x_int = rcp_static_cast<const Integer>(x);
3292 if (x_int->is_positive()) {
3293 if (is_a<Integer>(*y)) {
3294 RCP<const Integer> y_int = rcp_static_cast<const Integer>(y);
3295 if (y_int->is_positive()) {
3296 return div(
3297 mul(gamma_positive_int(x), gamma_positive_int(y)),
3298 gamma_positive_int(add(x, y)));
3299 } else {
3300 return ComplexInf;
3301 }
3302 } else if (is_a<Rational>(*y)) {
3303 RCP<const Rational> y_ = rcp_static_cast<const Rational>(y);
3304 if (get_den(y_->as_rational_class()) == 2) {
3305 return div(mul(gamma_positive_int(x), gamma_multiple_2(y)),
3306 gamma_multiple_2(add(x, y)));
3307 } else {
3308 return Beta::from_two_basic(x, y);
3309 }
3310 }
3311 } else {
3312 return ComplexInf;
3313 }
3314 }
3315
3316 if (is_a<Integer>(*y)) {
3317 RCP<const Integer> y_int = rcp_static_cast<const Integer>(y);
3318 if (y_int->is_positive()) {
3319 if (is_a<Rational>(*x)) {
3320 RCP<const Rational> x_ = rcp_static_cast<const Rational>(x);
3321 if (get_den(x_->as_rational_class()) == 2) {
3322 return div(mul(gamma_positive_int(y), gamma_multiple_2(x)),
3323 gamma_multiple_2(add(x, y)));
3324 } else {
3325 return Beta::from_two_basic(x, y);
3326 }
3327 }
3328 } else {
3329 return ComplexInf;
3330 }
3331 }
3332
3333 if (is_a<const Rational>(*x)
3334 and get_den(down_cast<const Rational &>(*x).as_rational_class()) == 2) {
3335 if (is_a<Integer>(*y)) {
3336 RCP<const Integer> y_int = rcp_static_cast<const Integer>(y);
3337 if (y_int->is_positive()) {
3338 return div(mul(gamma_multiple_2(x), gamma_positive_int(y)),
3339 gamma_multiple_2(add(x, y)));
3340 } else {
3341 return ComplexInf;
3342 }
3343 }
3344 if (is_a<const Rational>(*y)
3345 and get_den((down_cast<const Rational &>(*y)).as_rational_class())
3346 == 2) {
3347 return div(mul(gamma_multiple_2(x), gamma_multiple_2(y)),
3348 gamma_positive_int(add(x, y)));
3349 }
3350 }
3351 return Beta::from_two_basic(x, y);
3352}

◆ binomial()

RCP< const Integer > SymEngine::binomial ( const Integer n,
unsigned long  k 
)

Binomial Coefficient.

Definition at line 145 of file ntheory.cpp.

146{
147 integer_class f;
148 mp_bin_ui(f, n.as_integer_class(), k);
149 return integer(std::move(f));
150}
const integer_class & as_integer_class() const
Convert to integer_class.
Definition: integer.h:45
std::enable_if< std::is_integral< T >::value, RCP< constInteger > >::type integer(T i)
Definition: integer.h:197

◆ bit_length()

template<typename T >
unsigned int SymEngine::bit_length ( t)

Definition at line 14 of file uintpoly.h.

15{
16 unsigned int count = 0;
17 while (t > 0) {
18 count++;
19 t = t >> 1;
20 }
21 return count;
22}

◆ boolean()

RCP< const BooleanAtom > SymEngine::boolean ( bool  b)
inline

Definition at line 46 of file logic.h.

47{
48 return b ? boolTrue : boolFalse;
49}

◆ boundary()

RCP< const Set > SymEngine::boundary ( const Set s)

Definition at line 277 of file set_funcs.cpp.

278{
279 BoundaryVisitor visitor;
280 return visitor.apply(s);
281}

◆ c89code()

std::string SymEngine::c89code ( const Basic x)
inline

Definition at line 359 of file codegen.cpp.

360{
362 return p.apply(x);
363}

◆ c99code()

std::string SymEngine::c99code ( const Basic x)
inline

Definition at line 365 of file codegen.cpp.

366{
368 return p.apply(x);
369}

◆ cancel()

template<typename Poly >
void SymEngine::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 
)
inline

Definition at line 11 of file cancel.h.

15{
16 // Converting basic to Poly
17 umap_basic_num numer_gens = _find_gens_poly(numer);
18 umap_basic_num denom_gens = _find_gens_poly(denom);
19
20 if (numer_gens.size() != 1 && denom_gens.size() != 1) {
21 // only considering univariate here
22 return;
23 }
24 RCP<const Basic> numer_var = numer_gens.begin()->first;
25 RCP<const Basic> denom_var = denom_gens.begin()->first;
26
27 RCP<const Poly> numer_poly = from_basic<Poly>(numer, numer_var);
28 RCP<const Poly> denom_poly = from_basic<Poly>(denom, denom_var);
29
30 // Finding common factors of numer_poly and denom_poly
31 RCP<const Poly> gcd_poly = gcd_upoly(*numer_poly, *denom_poly);
32
33 // Dividing both by common factors
34 divides_upoly(*gcd_poly, *numer_poly, outArg(*result_numer));
35 divides_upoly(*gcd_poly, *denom_poly, outArg(*result_denom));
36 *common = gcd_poly;
37}
T size(T... args)

◆ canonicalize()

void SymEngine::canonicalize ( rational_class &  i)
inline

Definition at line 291 of file mp_class.h.

292{
293 i.canonicalize();
294}

◆ carmichael()

RCP< const Integer > SymEngine::carmichael ( const RCP< const Integer > &  n)

Carmichael function.

Definition at line 812 of file ntheory.cpp.

813{
814 if (n->is_zero())
815 return integer(1);
816
817 map_integer_uint prime_mul;
818 integer_class lambda, t, p;
819 unsigned multiplicity;
820
821 prime_factor_multiplicities(prime_mul, *n);
822 lambda = 1;
823 for (const auto &it : prime_mul) {
824 p = it.first->as_integer_class();
825 multiplicity = it.second;
826 if (p == 2
827 and multiplicity
828 > 2) { // For powers of 2 greater than 4 divide by 2.
829 multiplicity--;
830 }
831 t = p - 1;
832 mp_lcm(lambda, lambda, t);
833 mp_pow_ui(t, p, multiplicity - 1);
834 // lambda and p are relatively prime.
835 lambda = lambda * t;
836 }
837 return integer(std::move(lambda));
838}
void prime_factor_multiplicities(map_integer_uint &primes_mul, const Integer &n)
Find multiplicities of prime factors of n
Definition: ntheory.cpp:461

◆ cbrt() [1/2]

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}

◆ cbrt() [2/2]

RCP< const Basic > SymEngine::cbrt ( RCP< const Basic > &  arg)

Definition at line 18 of file functions.cpp.

19{
20 return pow(arg, div(one, i3));
21}

◆ ccode()

std::string SymEngine::ccode ( const Basic x)

Definition at line 347 of file codegen.cpp.

348{
350 return c.apply(x);
351}

◆ ceiling()

RCP< const Basic > SymEngine::ceiling ( const RCP< const Basic > &  arg)

Canonicalize Ceiling:

Definition at line 705 of file functions.cpp.

706{
707 if (is_a_Number(*arg)) {
708 if (down_cast<const Number &>(*arg).is_exact()) {
709 if (is_a<Rational>(*arg)) {
710 const Rational &s = down_cast<const Rational &>(*arg);
711 integer_class quotient;
712 mp_cdiv_q(quotient, SymEngine::get_num(s.as_rational_class()),
713 SymEngine::get_den(s.as_rational_class()));
714 return integer(std::move(quotient));
715 }
716 return arg;
717 }
718 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
719 return _arg->get_eval().ceiling(*_arg);
720 }
721 if (is_a<Constant>(*arg)) {
722 if (eq(*arg, *pi)) {
723 return integer(4);
724 }
725 if (eq(*arg, *E)) {
726 return integer(3);
727 }
728 if (eq(*arg, *GoldenRatio)) {
729 return integer(2);
730 }
731 if (eq(*arg, *Catalan) or eq(*arg, *EulerGamma)) {
732 return integer(1);
733 }
734 }
735 if (is_a<Floor>(*arg)) {
736 return arg;
737 }
738 if (is_a<Ceiling>(*arg)) {
739 return arg;
740 }
741 if (is_a<Truncate>(*arg)) {
742 return arg;
743 }
744 if (is_a<BooleanAtom>(*arg) or is_a_Relational(*arg)) {
745 throw SymEngineException(
746 "Boolean objects not allowed in this context.");
747 }
748 if (is_a<Add>(*arg)) {
749 RCP<const Number> s = down_cast<const Add &>(*arg).get_coef();
750 umap_basic_num d = down_cast<const Add &>(*arg).get_dict();
751 if (is_a<Integer>(*s)) {
752 return add(
753 s, make_rcp<const Ceiling>(Add::from_dict(zero, std::move(d))));
754 }
755 }
756 return make_rcp<const Ceiling>(arg);
757}
Rational Class.
Definition: rational.h:16
const rational_class & as_rational_class() const
Convert to rational_class.
Definition: rational.h:50
RCP< const Integer > quotient(const Integer &n, const Integer &d)
Definition: ntheory.cpp:71

◆ CEREAL_LOAD_FUNCTION_NAME()

template<class Archive , class T >
void SymEngine::CEREAL_LOAD_FUNCTION_NAME ( Archive &  ar,
RCP< const T > &  ptr 
)
inline

Loading for SymEngine::RCP.

Definition at line 666 of file serialize-cereal.h.

667{
668 uint32_t id;
669 ar(CEREAL_NVP(id));
670
671 if (id & cereal::detail::msb_32bit) {
672 TypeID type_code;
673 ar(type_code);
674 switch (type_code) {
675#define SYMENGINE_ENUM(type_enum, Class) \
676 case type_enum: { \
677 if (not std::is_base_of<T, Class>::value) { \
678 throw std::runtime_error("Cannot convert to type."); \
679 } else { \
680 RCP<const Class> dummy_ptr; \
681 ptr = rcp_static_cast<const T>( \
682 rcp_static_cast<const Basic>(load_basic(ar, dummy_ptr))); \
683 break; \
684 } \
685 }
686#include "symengine/type_codes.inc"
687#undef SYMENGINE_ENUM
688 default:
689 throw std::runtime_error("Unknown type");
690 }
691 std::shared_ptr<void> sharedPtr = std::static_pointer_cast<void>(
692 std::make_shared<RCP<const Basic>>(ptr));
693
694 ar.registerSharedPointer(id, sharedPtr);
695 } else {
697 = std::static_pointer_cast<RCP<const T>>(ar.getSharedPointer(id));
698 ptr = *sharedPtr.get();
699 }
700}
T get(T... args)
T make_shared(T... args)
TypeID
Definition: basic.h:43

◆ CEREAL_SAVE_FUNCTION_NAME()

template<class Archive , class T >
void SymEngine::CEREAL_SAVE_FUNCTION_NAME ( Archive &  ar,
RCP< const T > const &  ptr 
)
inline

Saving for SymEngine::RCP.

Definition at line 309 of file serialize-cereal.h.

310{
311 save_basic(ar, rcp_static_cast<const Basic>(ptr));
312}

◆ char_poly()

void SymEngine::char_poly ( const DenseMatrix A,
DenseMatrix B 
)

Definition at line 1841 of file dense_matrix.cpp.

1842{
1843 SYMENGINE_ASSERT(B.ncols() == 1 and B.nrows() == A.nrows() + 1);
1844 SYMENGINE_ASSERT(A.nrows() == A.ncols());
1845
1847
1848 berkowitz(A, polys);
1849 B = polys[polys.size() - 1];
1850}

◆ check_matching_mul_sizes()

void SymEngine::check_matching_mul_sizes ( const vec_basic vec)

Definition at line 152 of file matrix_mul.cpp.

153{
154 auto first_size = size(down_cast<const MatrixExpr &>(*vec[0]));
155 for (size_t i = 1; i < vec.size(); i++) {
156 auto second_size = size(down_cast<const MatrixExpr &>(*vec[i]));
157 if (first_size.second.is_null() || second_size.first.is_null()) {
158 first_size = second_size;
159 continue;
160 }
161 auto diff = sub(first_size.second, second_size.first);
162 tribool match = is_zero(*diff);
163 if (is_false(match)) {
164 throw DomainError("Matrix dimension mismatch");
165 }
166 first_size = second_size;
167 }
168}

◆ check_matching_sizes()

void SymEngine::check_matching_sizes ( const vec_basic vec)

Definition at line 60 of file matrix_add.cpp.

61{
62 for (size_t i = 0; i < vec.size() - 1; i++) {
63 auto first_size = size(down_cast<const MatrixExpr &>(*vec[i]));
64 if (first_size.first.is_null()) {
65 continue;
66 }
67 for (size_t j = 1; j < vec.size(); j++) {
68 auto second_size = size(down_cast<const MatrixExpr &>(*vec[j]));
69 if (second_size.first.is_null()) {
70 continue;
71 }
72 auto rowdiff = sub(first_size.first, second_size.first);
73 tribool rowmatch = is_zero(*rowdiff);
74 if (is_false(rowmatch)) {
75 throw DomainError("Matrix dimension mismatch");
76 }
77 auto coldiff = sub(first_size.second, second_size.second);
78 tribool colmatch = is_zero(*coldiff);
79 if (is_false(colmatch)) {
80 throw DomainError("Matrix dimension mismatch");
81 }
82 }
83 }
84}

◆ cholesky()

void SymEngine::cholesky ( const DenseMatrix A,
DenseMatrix L 
)

Definition at line 1638 of file dense_matrix.cpp.

1639{
1640 SYMENGINE_ASSERT(A.row_ == A.col_);
1641 SYMENGINE_ASSERT(L.row_ == A.row_ and L.col_ == A.row_);
1642
1643 unsigned col = A.col_;
1644 unsigned i, j, k;
1645 RCP<const Basic> sum;
1646 RCP<const Basic> i2 = integer(2);
1647 RCP<const Basic> half = div(one, i2);
1648
1649 // Initialize L
1650 for (i = 0; i < col; i++)
1651 for (j = 0; j < col; j++)
1652 L.m_[i * col + j] = zero;
1653
1654 for (i = 0; i < col; i++) {
1655 for (j = 0; j < i; j++) {
1656 sum = zero;
1657 for (k = 0; k < j; k++)
1658 sum = add(sum, mul(L.m_[i * col + k], L.m_[j * col + k]));
1659
1660 L.m_[i * col + j]
1661 = mul(div(one, L.m_[j * col + j]), sub(A.m_[i * col + j], sum));
1662 }
1663 sum = zero;
1664 for (k = 0; k < i; k++)
1665 sum = add(sum, pow(L.m_[i * col + k], i2));
1666 L.m_[i * col + i] = pow(sub(A.m_[i * col + i], sum), half);
1667 }
1668}

◆ closure()

RCP< const Set > SymEngine::closure ( const Set s)

Definition at line 289 of file set_funcs.cpp.

290{
291 return s.set_union(boundary(s));
292}

◆ coeff()

RCP< const Basic > SymEngine::coeff ( const Basic b,
const Basic x,
const Basic n 
)

Definition at line 63 of file visitor.cpp.

64{
65 if (!(is_a<Symbol>(x) || is_a<FunctionSymbol>(x))) {
66 throw NotImplementedError("Not implemented for non (Function)Symbols.");
67 }
68 CoeffVisitor v(ptrFromRef(x), ptrFromRef(n));
69 return v.apply(b);
70}

◆ column_exchange_dense()

void SymEngine::column_exchange_dense ( DenseMatrix A,
unsigned  i,
unsigned  j 
)

Definition at line 864 of file dense_matrix.cpp.

865{
866 SYMENGINE_ASSERT(i != j and i < A.col_ and j < A.col_);
867
868 unsigned col = A.col_;
869
870 for (unsigned k = 0; k < A.row_; k++)
871 std::swap(A.m_[k * col + i], A.m_[k * col + j]);
872}
T swap(T... args)

◆ complex_double()

RCP< const ComplexDouble > SymEngine::complex_double ( std::complex< double >  x)

Definition at line 62 of file complex_double.cpp.

63{
64 return make_rcp<const ComplexDouble>(x);
65}

◆ complexes()

RCP< const Complexes > SymEngine::complexes ( )
inline
Returns
RCP<const Complexes>

Definition at line 554 of file sets.h.

555{
556 return Complexes::getInstance();
557}

◆ conditionset()

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

Definition at line 1781 of file sets.cpp.

1783{
1784 if (eq(*condition, *boolean(false))) {
1785 return emptyset();
1786 } else if (eq(*condition, *boolean(true))) {
1787 return universalset();
1788 }
1789 if (is_a<And>(*condition)) {
1790 auto cont = down_cast<const And &>(*condition).get_container();
1791 set_boolean newcont;
1792 set_basic present, others;
1793 for (auto it = cont.begin(); it != cont.end(); it++) {
1794 if (is_a<Contains>(**it)
1795 and eq(*down_cast<const Contains &>(**it).get_expr(), *sym)
1796 and is_a<FiniteSet>(
1797 *down_cast<const Contains &>(**it).get_set())) {
1798 auto fset = down_cast<const Contains &>(**it).get_set();
1799 auto fcont
1800 = down_cast<const FiniteSet &>(*fset).get_container();
1801 // use the result of simplification done in `logical_and()`
1802 for (const auto &elem : fcont) {
1803 if (not(is_a_Number(*elem) or is_a<Constant>(*elem))) {
1804 others.insert(elem);
1805 } else {
1806 // logical_and() doesn't guarantee that if element of a
1807 // finiteset is a number, then it satisfies other
1808 // conditions
1809 // it only assures that there doesn't exist any such
1810 // element of finiteset that surely fails in other
1811 // conditions.
1812 auto restCont = cont;
1813 restCont.erase(*it);
1814 auto restCond = logical_and(restCont);
1815 map_basic_basic d;
1816 d[sym] = elem;
1817 auto contain = restCond->subs(d);
1818 if (eq(*contain, *boolean(true))) {
1819 present.insert(elem);
1820 } else if (not eq(*contain, *boolean(false))) {
1821 others.insert(elem);
1822 } else {
1823 throw SymEngineException("element should have "
1824 "been removed within "
1825 "logical_and()");
1826 }
1827 }
1828 }
1829 } else {
1830 newcont.insert(*it);
1831 }
1832 }
1833 if (not present.empty()) {
1834 newcont.insert(finiteset(others)->contains(sym));
1835 return SymEngine::set_union(
1836 {finiteset(present), conditionset(sym, logical_and(newcont))});
1837 }
1838 }
1839 if (is_a<Contains>(*condition)) {
1840 return down_cast<const Contains &>(*condition).get_set();
1841 }
1842 return make_rcp<const ConditionSet>(sym, condition);
1843}
RCP< const EmptySet > emptyset()
Definition: sets.h:590
RCP< const Set > conditionset(const RCP< const Basic > &sym, const RCP< const Boolean > &condition)
Definition: sets.cpp:1781

◆ conjugate()

RCP< const Basic > SymEngine::conjugate ( const RCP< const Basic > &  arg)

Canonicalize Conjugate.

Definition at line 149 of file functions.cpp.

150{
151 if (is_a_Number(*arg)) {
152 return down_cast<const Number &>(*arg).conjugate();
153 }
154 if (is_a<Constant>(*arg) or is_a<Abs>(*arg) or is_a<KroneckerDelta>(*arg)
155 or is_a<LeviCivita>(*arg)) {
156 return arg;
157 }
158 if (is_a<Mul>(*arg)) {
159 const map_basic_basic &dict = down_cast<const Mul &>(*arg).get_dict();
160 map_basic_basic new_dict;
161 RCP<const Number> coef = rcp_static_cast<const Number>(
162 conjugate(down_cast<const Mul &>(*arg).get_coef()));
163 for (const auto &p : dict) {
164 if (is_a<Integer>(*p.second)) {
165 Mul::dict_add_term_new(outArg(coef), new_dict, p.second,
166 conjugate(p.first));
167 } else {
168 Mul::dict_add_term_new(
169 outArg(coef), new_dict, one,
170 conjugate(Mul::from_dict(one, {{p.first, p.second}})));
171 }
172 }
173 return Mul::from_dict(coef, std::move(new_dict));
174 }
175 if (is_a<Pow>(*arg)) {
176 RCP<const Basic> base = down_cast<const Pow &>(*arg).get_base();
177 RCP<const Basic> exp = down_cast<const Pow &>(*arg).get_exp();
178 if (is_a<Integer>(*exp)) {
179 return pow(conjugate(base), exp);
180 }
181 }
182 if (is_a<Conjugate>(*arg)) {
183 return down_cast<const Conjugate &>(*arg).get_arg();
184 }
185 if (is_a<Sign>(*arg) or is_a<Erf>(*arg) or is_a<Erfc>(*arg)
186 or is_a<Gamma>(*arg) or is_a<LogGamma>(*arg) or is_a<Sin>(*arg)
187 or is_a<Cos>(*arg) or is_a<Tan>(*arg) or is_a<Cot>(*arg)
188 or is_a<Sec>(*arg) or is_a<Csc>(*arg) or is_a<Sinh>(*arg)
189 or is_a<Cosh>(*arg) or is_a<Tanh>(*arg) or is_a<Coth>(*arg)
190 or is_a<Sech>(*arg) or is_a<Csch>(*arg)) {
191 const OneArgFunction &func = down_cast<const OneArgFunction &>(*arg);
192 return func.create(conjugate(func.get_arg()));
193 }
194 if (is_a<ATan2>(*arg) or is_a<LowerGamma>(*arg) or is_a<UpperGamma>(*arg)
195 or is_a<Beta>(*arg)) {
196 const TwoArgFunction &func = down_cast<const TwoArgFunction &>(*arg);
197 return func.create(conjugate(func.get_arg1()),
198 conjugate(func.get_arg2()));
199 }
200 return make_rcp<const Conjugate>(arg);
201}
T exp(T... args)
RCP< const Basic > conjugate(const RCP< const Basic > &arg)
Canonicalize Conjugate.
Definition: functions.cpp:149
T pow(T... args)

◆ conjugate_dense()

void SymEngine::conjugate_dense ( const DenseMatrix A,
DenseMatrix B 
)

Definition at line 603 of file dense_matrix.cpp.

604{
605 SYMENGINE_ASSERT(B.col_ == A.col_ and B.row_ == A.row_);
606
607 for (unsigned i = 0; i < A.row_; i++)
608 for (unsigned j = 0; j < A.col_; j++)
609 B.m_[i * B.col_ + j] = conjugate(A.m_[i * A.col_ + j]);
610}

◆ conjugate_matrix()

RCP< const MatrixExpr > SymEngine::conjugate_matrix ( const RCP< const MatrixExpr > &  arg)

Definition at line 134 of file conjugate_matrix.cpp.

135{
137 return visitor.apply(*arg);
138}

◆ conjugate_transpose_dense()

void SymEngine::conjugate_transpose_dense ( const DenseMatrix A,
DenseMatrix B 
)

Definition at line 623 of file dense_matrix.cpp.

624{
625 SYMENGINE_ASSERT(B.row_ == A.col_ and B.col_ == A.row_);
626
627 for (unsigned i = 0; i < A.row_; i++)
628 for (unsigned j = 0; j < A.col_; j++)
629 B.m_[j * B.col_ + i] = conjugate(A.m_[i * A.col_ + j]);
630}

◆ constant()

RCP< const Constant > SymEngine::constant ( const std::string name)
inline

inline version to return Constant

Definition at line 53 of file constants.h.

54{
55 return make_rcp<const Constant>(name);
56}

◆ contains()

RCP< const Boolean > SymEngine::contains ( const RCP< const Basic > &  expr,
const RCP< const Set > &  set 
)

Definition at line 116 of file logic.cpp.

118{
119 if (is_a_Number(*expr) or is_a_Set(*expr)) {
120 return set->contains(expr);
121 } else {
122 return make_rcp<Contains>(expr, set);
123 }
124}

◆ cos()

RCP< const Basic > SymEngine::cos ( const RCP< const Basic > &  arg)

Canonicalize Cos:

Definition at line 942 of file functions.cpp.

943{
944 if (eq(*arg, *zero))
945 return one;
946 if (is_a_Number(*arg) and not down_cast<const Number &>(*arg).is_exact()) {
947 return down_cast<const Number &>(*arg).get_eval().cos(*arg);
948 }
949
950 if (is_a<ACos>(*arg)) {
951 return down_cast<const ACos &>(*arg).get_arg();
952 } else if (is_a<ASec>(*arg)) {
953 return div(one, down_cast<const ASec &>(*arg).get_arg());
954 }
955
956 RCP<const Basic> ret_arg;
957 int index, sign;
958 bool conjugate = trig_simplify(arg, 2, false, true, // input
959 outArg(ret_arg), index, sign); // output
960
961 if (conjugate) {
962 // sin has to be returned
963 if (sign == 1) {
964 return sin(ret_arg);
965 } else {
966 return mul(minus_one, sin(ret_arg));
967 }
968 } else {
969 if (eq(*ret_arg, *zero)) {
970 return mul(integer(sign), sin_table()[(index + 6) % 24]);
971 } else {
972 if (sign == 1) {
973 if (neq(*ret_arg, *arg)) {
974 return cos(ret_arg);
975 } else {
976 return make_rcp<const Cos>(ret_arg);
977 }
978 } else {
979 return mul(minus_one, cos(ret_arg));
980 }
981 }
982 }
983}
T cos(T... args)
RCP< const Basic > sign(const RCP< const Basic > &arg)
Canonicalize Sign.
Definition: functions.cpp:527
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
Definition: basic-inl.h:29
T sin(T... args)

◆ cosh()

RCP< const Basic > SymEngine::cosh ( const RCP< const Basic > &  arg)

Canonicalize Cosh:

Definition at line 2212 of file functions.cpp.

2213{
2214 if (eq(*arg, *zero))
2215 return one;
2216 if (is_a_Number(*arg)) {
2217 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2218 if (not _arg->is_exact()) {
2219 return _arg->get_eval().cosh(*_arg);
2220 } else if (_arg->is_negative()) {
2221 return cosh(zero->sub(*_arg));
2222 }
2223 }
2224 RCP<const Basic> d;
2225 handle_minus(arg, outArg(d));
2226 return make_rcp<const Cosh>(d);
2227}

◆ cot()

RCP< const Basic > SymEngine::cot ( const RCP< const Basic > &  arg)

Canonicalize Cot:

Definition at line 1073 of file functions.cpp.

1074{
1075 if (is_a_Number(*arg) and not down_cast<const Number &>(*arg).is_exact()) {
1076 return down_cast<const Number &>(*arg).get_eval().cot(*arg);
1077 }
1078
1079 if (is_a<ACot>(*arg)) {
1080 return down_cast<const ACot &>(*arg).get_arg();
1081 } else if (is_a<ATan>(*arg)) {
1082 return div(one, down_cast<const ATan &>(*arg).get_arg());
1083 }
1084
1085 RCP<const Basic> ret_arg;
1086 int index, sign;
1087 bool conjugate = trig_simplify(arg, 1, true, true, // input
1088 outArg(ret_arg), index, sign); // output
1089
1090 if (conjugate) {
1091 // tan has to be returned
1092 if (sign == 1) {
1093 return tan(ret_arg);
1094 } else {
1095 return mul(minus_one, tan(ret_arg));
1096 }
1097 } else {
1098 if (eq(*ret_arg, *zero)) {
1099 return mul(integer(sign),
1100 div(sin_table()[(index + 6) % 24], sin_table()[index]));
1101 } else {
1102 if (sign == 1) {
1103 if (neq(*ret_arg, *arg)) {
1104 return cot(ret_arg);
1105 } else {
1106 return make_rcp<const Cot>(ret_arg);
1107 }
1108 } else {
1109 return mul(minus_one, cot(ret_arg));
1110 }
1111 }
1112 }
1113}
RCP< const Basic > cot(const RCP< const Basic > &arg)
Canonicalize Cot:
Definition: functions.cpp:1073
T tan(T... args)

◆ coth()

RCP< const Basic > SymEngine::coth ( const RCP< const Basic > &  arg)

Canonicalize Coth:

Definition at line 2333 of file functions.cpp.

2334{
2335 if (eq(*arg, *zero)) {
2336 return ComplexInf;
2337 }
2338 if (is_a_Number(*arg)) {
2339 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2340 if (not _arg->is_exact()) {
2341 return _arg->get_eval().coth(*_arg);
2342 } else if (_arg->is_negative()) {
2343 return neg(coth(zero->sub(*_arg)));
2344 }
2345 }
2346 RCP<const Basic> d;
2347 bool b = handle_minus(arg, outArg(d));
2348 if (b) {
2349 return neg(coth(d));
2350 }
2351 return make_rcp<const Coth>(d);
2352}
RCP< const Basic > coth(const RCP< const Basic > &arg)
Canonicalize Coth:
Definition: functions.cpp:2333

◆ could_extract_minus()

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

Definition at line 325 of file functions.cpp.

326{
327 if (is_a_Number(arg)) {
328 if (down_cast<const Number &>(arg).is_negative()) {
329 return true;
330 } else if (is_a_Complex(arg)) {
331 const ComplexBase &c = down_cast<const ComplexBase &>(arg);
332 RCP<const Number> real_part = c.real_part();
333 return (real_part->is_negative())
334 or (eq(*real_part, *zero)
335 and c.imaginary_part()->is_negative());
336 } else {
337 return false;
338 }
339 } else if (is_a<Mul>(arg)) {
340 const Mul &s = down_cast<const Mul &>(arg);
341 return could_extract_minus(*s.get_coef());
342 } else if (is_a<Add>(arg)) {
343 const Add &s = down_cast<const Add &>(arg);
344 if (s.get_coef()->is_zero()) {
345 map_basic_num d(s.get_dict().begin(), s.get_dict().end());
346 return could_extract_minus(*d.begin()->second);
347 } else {
348 return could_extract_minus(*s.get_coef());
349 }
350 } else {
351 return false;
352 }
353}
bool could_extract_minus(const Basic &arg)
Definition: functions.cpp:325

◆ count_ops()

unsigned SymEngine::count_ops ( const vec_basic a)

Definition at line 314 of file visitor.cpp.

315{
317 for (auto &p : a) {
318 v.apply(*p);
319 }
320 return v.count;
321}

◆ cross()

void SymEngine::cross ( const DenseMatrix A,
const DenseMatrix B,
DenseMatrix C 
)

Definition at line 1962 of file dense_matrix.cpp.

1963{
1964 SYMENGINE_ASSERT((A.row_ * A.col_ == 3 and B.row_ * B.col_ == 3)
1965 and (A.row_ == C.row_ and A.col_ == C.col_));
1966
1967 C.m_[0] = sub(mul(A.m_[1], B.m_[2]), mul(A.m_[2], B.m_[1]));
1968 C.m_[1] = sub(mul(A.m_[2], B.m_[0]), mul(A.m_[0], B.m_[2]));
1969 C.m_[2] = sub(mul(A.m_[0], B.m_[1]), mul(A.m_[1], B.m_[0]));
1970}

◆ crt()

bool SymEngine::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.

Definition at line 552 of file ntheory.cpp.

555{
556 if (mod.size() > rem.size())
557 throw SymEngineException("Too few remainders");
558 if (mod.size() == 0)
559 throw SymEngineException("Moduli vector cannot be empty");
560
561 integer_class m, r, g, s, t;
562 m = mod[0]->as_integer_class();
563 r = rem[0]->as_integer_class();
564
565 for (unsigned i = 1; i < mod.size(); ++i) {
566 mp_gcdext(g, s, t, m, mod[i]->as_integer_class());
567 // g = s * m + t * mod[i]
568 t = rem[i]->as_integer_class() - r;
569 if (not mp_divisible_p(t, g))
570 return false;
571 r += m * s * (t / g); // r += m * (m**-1 mod[i]/g)* (rem[i] - r) / g
572 m *= mod[i]->as_integer_class() / g;
573 mp_fdiv_r(r, r, m);
574 }
575 *R = integer(std::move(r));
576 return true;
577}
RCP< const Integer > mod(const Integer &n, const Integer &d)
modulo round toward zero
Definition: ntheory.cpp:66

◆ csc()

RCP< const Basic > SymEngine::csc ( const RCP< const Basic > &  arg)

Canonicalize Csc:

Definition at line 1138 of file functions.cpp.

1139{
1140 if (is_a_Number(*arg) and not down_cast<const Number &>(*arg).is_exact()) {
1141 return down_cast<const Number &>(*arg).get_eval().csc(*arg);
1142 }
1143
1144 if (is_a<ACsc>(*arg)) {
1145 return down_cast<const ACsc &>(*arg).get_arg();
1146 } else if (is_a<ASin>(*arg)) {
1147 return div(one, down_cast<const ASin &>(*arg).get_arg());
1148 }
1149
1150 RCP<const Basic> ret_arg;
1151 int index, sign;
1152 bool conjugate = trig_simplify(arg, 2, true, false, // input
1153 outArg(ret_arg), index, sign); // output
1154
1155 if (conjugate) {
1156 // cos has to be returned
1157 if (sign == 1) {
1158 return sec(ret_arg);
1159 } else {
1160 return mul(minus_one, sec(ret_arg));
1161 }
1162 } else {
1163 if (eq(*ret_arg, *zero)) {
1164 return mul(integer(sign), div(one, sin_table()[index]));
1165 } else {
1166 if (sign == 1) {
1167 if (neq(*ret_arg, *arg)) {
1168 return csc(ret_arg);
1169 } else {
1170 return make_rcp<const Csc>(ret_arg);
1171 }
1172 } else {
1173 return mul(minus_one, csc(ret_arg));
1174 }
1175 }
1176 }
1177}
RCP< const Basic > sec(const RCP< const Basic > &arg)
Canonicalize Sec:
Definition: functions.cpp:1202
RCP< const Basic > csc(const RCP< const Basic > &arg)
Canonicalize Csc:
Definition: functions.cpp:1138

◆ csch()

RCP< const Basic > SymEngine::csch ( const RCP< const Basic > &  arg)

Canonicalize Csch:

Definition at line 2169 of file functions.cpp.

2170{
2171 if (eq(*arg, *zero)) {
2172 return ComplexInf;
2173 }
2174 if (is_a_Number(*arg)) {
2175 RCP<const Number> _arg = rcp_static_cast<const Number>(arg);
2176 if (not _arg->is_exact()) {
2177 return _arg->get_eval().csch(*_arg);
2178 } else if (_arg->is_negative()) {
2179 return neg(csch(zero->sub(*_arg)));
2180 }
2181 }
2182 RCP<const Basic> d;
2183 bool b = handle_minus(arg, outArg(d));
2184 if (b) {
2185 return neg(csch(d));
2186 }
2187 return make_rcp<const Csch>(d);
2188}
RCP< const Basic > csch(const RCP< const Basic > &arg)
Canonicalize Csch:
Definition: functions.cpp:2169

◆ cse()

void SymEngine::cse ( vec_pair replacements,
vec_basic reduced_exprs,
const vec_basic exprs 
)

Definition at line 547 of file cse.cpp.

549{
550 // Find other optimization opportunities.
551 umap_basic_basic opt_subs = opt_cse(exprs);
552
553 // Main CSE algorithm.
554 tree_cse(replacements, reduced_exprs, exprs, opt_subs);
555}

◆ csr_binop_csr_canonical()

void SymEngine::csr_binop_csr_canonical ( const CSRMatrix A,
const CSRMatrix B,
CSRMatrix C,
RCP< const Basic >(&)(const RCP< const Basic > &, const RCP< const Basic > &)  bin_op 
)

Definition at line 689 of file sparse_matrix.cpp.

693{
694 SYMENGINE_ASSERT(A.row_ == B.row_ and A.col_ == B.col_ and C.row_ == A.row_
695 and C.col_ == A.col_);
696
697 // Method that works for canonical CSR matrices
698 C.p_[0] = 0;
699 C.j_.clear();
700 C.x_.clear();
701 unsigned nnz = 0;
702 unsigned A_pos, B_pos, A_end, B_end;
703
704 for (unsigned i = 0; i < A.row_; i++) {
705 A_pos = A.p_[i];
706 B_pos = B.p_[i];
707 A_end = A.p_[i + 1];
708 B_end = B.p_[i + 1];
709
710 // while not finished with either row
711 while (A_pos < A_end and B_pos < B_end) {
712 unsigned A_j = A.j_[A_pos];
713 unsigned B_j = B.j_[B_pos];
714
715 if (A_j == B_j) {
716 RCP<const Basic> result = bin_op(A.x_[A_pos], B.x_[B_pos]);
717 if (!is_true(is_zero(*result))) {
718 C.j_.push_back(A_j);
719 C.x_.push_back(result);
720 nnz++;
721 }
722 A_pos++;
723 B_pos++;
724 } else if (A_j < B_j) {
725 RCP<const Basic> result = bin_op(A.x_[A_pos], zero);
726 if (!is_true(is_zero(*result))) {
727 C.j_.push_back(A_j);
728 C.x_.push_back(result);
729 nnz++;
730 }
731 A_pos++;
732 } else {
733 // B_j < A_j
734 RCP<const Basic> result = bin_op(zero, B.x_[B_pos]);
735 if (!is_true(is_zero(*result))) {
736 C.j_.push_back(B_j);
737 C.x_.push_back(result);
738 nnz++;
739 }
740 B_pos++;
741 }
742 }
743
744 // tail
745 while (A_pos < A_end) {
746 RCP<const Basic> result = bin_op(A.x_[A_pos], zero);
747 if (!is_true(is_zero(*result))) {
748 C.j_.push_back(A.j_[A_pos]);
749 C.x_.push_back(result);
750 nnz++;
751 }
752 A_pos++;
753 }
754 while (B_pos < B_end) {
755 RCP<const Basic> result = bin_op(zero, B.x_[B_pos]);
756 if (!is_true(is_zero(*result))) {
757 C.j_.push_back(B.j_[B_pos]);
758 C.x_.push_back(result);
759 nnz++;
760 }
761 B_pos++;
762 }
763
764 C.p_[i + 1] = nnz;
765 }
766
767 // It's enough to check for duplicates as the column indices
768 // remain sorted after the above operations
769 if (CSRMatrix::csr_has_duplicates(C.p_, C.j_, A.row_))
770 CSRMatrix::csr_sum_duplicates(C.p_, C.j_, C.x_, A.row_);
771}

◆ csr_diagonal()

void SymEngine::csr_diagonal ( const CSRMatrix A,
DenseMatrix D 
)

Definition at line 622 of file sparse_matrix.cpp.

623{
624 unsigned N = std::min(A.row_, A.col_);
625
626 SYMENGINE_ASSERT(D.nrows() == N and D.ncols() == 1);
627
628 unsigned row_start;
629 unsigned row_end;
630 RCP<const Basic> diag;
631
632 for (unsigned i = 0; i < N; i++) {
633 row_start = A.p_[i];
634 row_end = A.p_[i + 1];
635 diag = zero;
636 unsigned jj;
637
638 while (row_start <= row_end) {
639 jj = (row_start + row_end) / 2;
640 if (A.j_[jj] == i) {
641 diag = A.x_[jj];
642 break;
643 } else if (A.j_[jj] < i) {
644 row_start = jj + 1;
645 } else {
646 row_end = jj - 1;
647 }
648 }
649
650 D.set(i, 0, diag);
651 }
652}
T min(T... args)

◆ csr_matmat_pass1()

void SymEngine::csr_matmat_pass1 ( const CSRMatrix A,
const CSRMatrix B,
CSRMatrix C 
)

Definition at line 532 of file sparse_matrix.cpp.

533{
534 // method that uses O(n) temp storage
535 std::vector<unsigned> mask(A.col_, -1);
536 C.p_[0] = 0;
537
538 unsigned nnz = 0;
539 for (unsigned i = 0; i < A.row_; i++) {
540 // npy_intp row_nnz = 0;
541 unsigned row_nnz = 0;
542
543 for (unsigned jj = A.p_[i]; jj < A.p_[i + 1]; jj++) {
544 unsigned j = A.j_[jj];
545 for (unsigned kk = B.p_[j]; kk < B.p_[j + 1]; kk++) {
546 unsigned k = B.j_[kk];
547 if (mask[k] != i) {
548 mask[k] = i;
549 row_nnz++;
550 }
551 }
552 }
553
554 unsigned next_nnz = nnz + row_nnz;
555
556 // Addition overflow: http://www.cplusplus.com/articles/DE18T05o/
557 if (next_nnz < nnz) {
558 throw std::overflow_error("nnz of the result is too large");
559 }
560
561 nnz = next_nnz;
562 C.p_[i + 1] = nnz;
563 }
564}

◆ csr_matmat_pass2()

void SymEngine::csr_matmat_pass2 ( const CSRMatrix A,
const CSRMatrix B,
CSRMatrix C 
)

Definition at line 568 of file sparse_matrix.cpp.

569{
570 std::vector<int> next(A.col_, -1);
571 vec_basic sums(A.col_, zero);
572
573 unsigned nnz = 0;
574
575 C.p_[0] = 0;
576
577 for (unsigned i = 0; i < A.row_; i++) {
578 int head = -2;
579 unsigned length = 0;
580
581 unsigned jj_start = A.p_[i];
582 unsigned jj_end = A.p_[i + 1];
583 for (unsigned jj = jj_start; jj < jj_end; jj++) {
584 unsigned j = A.j_[jj];
585 RCP<const Basic> v = A.x_[jj];
586
587 unsigned kk_start = B.p_[j];
588 unsigned kk_end = B.p_[j + 1];
589 for (unsigned kk = kk_start; kk < kk_end; kk++) {
590 unsigned k = B.j_[kk];
591
592 sums[k] = add(sums[k], mul(v, B.x_[kk]));
593
594 if (next[k] == -1) {
595 next[k] = head;
596 head = k;
597 length++;
598 }
599 }
600 }
601
602 for (unsigned jj = 0; jj < length; jj++) {
603
604 if (!is_true(is_zero(*sums[head]))) {
605 C.j_[nnz] = head;
606 C.x_[nnz] = sums[head];
607 nnz++;
608 }
609
610 unsigned temp = head;
611 head = next[head];
612
613 next[temp] = -1; // clear arrays
614 sums[temp] = zero;
615 }
616
617 C.p_[i + 1] = nnz;
618 }
619}
T next(T... args)

◆ csr_scale_columns()

void SymEngine::csr_scale_columns ( CSRMatrix A,
const DenseMatrix X 
)

Definition at line 670 of file sparse_matrix.cpp.

671{
672 SYMENGINE_ASSERT(A.col_ == X.nrows() and X.ncols() == 1);
673
674 const unsigned nnz = A.p_[A.row_];
675 unsigned i;
676
677 for (i = 0; i < A.col_; i++) {
678 if (is_true(is_zero(*X.get(i, 0))))
679 throw SymEngineException("Scaling factor can't be zero");
680 }
681
682 for (i = 0; i < nnz; i++)
683 A.x_[i] = mul(A.x_[i], X.get(A.j_[i], 0));
684}

◆ csr_scale_rows()

void SymEngine::csr_scale_rows ( CSRMatrix A,
const DenseMatrix X 
)

Definition at line 656 of file sparse_matrix.cpp.

657{
658 SYMENGINE_ASSERT(A.row_ == X.nrows() and X.ncols() == 1);
659
660 for (unsigned i = 0; i < A.row_; i++) {
661 if (is_true(is_zero(*X.get(i, 0))))
662 throw SymEngineException("Scaling factor can't be zero");
663 for (unsigned jj = A.p_[i]; jj < A.p_[i + 1]; jj++)
664 A.x_[jj] = mul(A.x_[jj], X.get(i, 0));
665 }
666}

◆ det_bareis()

RCP< const Basic > SymEngine::det_bareis ( const DenseMatrix A)

Definition at line 1690 of file dense_matrix.cpp.

1691{
1692 SYMENGINE_ASSERT(A.row_ == A.col_);
1693
1694 unsigned n = A.row_;
1695
1696 if (n == 1) {
1697 return A.m_[0];
1698 } else if (n == 2) {
1699 // If A = [[a, b], [c, d]] then det(A) = ad - bc
1700 return sub(mul(A.m_[0], A.m_[3]), mul(A.m_[1], A.m_[2]));
1701 } else if (n == 3) {
1702 // if A = [[a, b, c], [d, e, f], [g, h, i]] then
1703 // det(A) = (aei + bfg + cdh) - (ceg + bdi + afh)
1704 return sub(add(add(mul(mul(A.m_[0], A.m_[4]), A.m_[8]),
1705 mul(mul(A.m_[1], A.m_[5]), A.m_[6])),
1706 mul(mul(A.m_[2], A.m_[3]), A.m_[7])),
1707 add(add(mul(mul(A.m_[2], A.m_[4]), A.m_[6]),
1708 mul(mul(A.m_[1], A.m_[3]), A.m_[8])),
1709 mul(mul(A.m_[0], A.m_[5]), A.m_[7])));
1710 } else {
1711
1712 if (A.is_lower() or A.is_upper()) {
1713 RCP<const Basic> det = A.m_[0];
1714 for (unsigned i = 1; i < n; ++i) {
1715 det = mul(det, A.m_[i * n + i]);
1716 }
1717 return det;
1718 }
1719
1720 DenseMatrix B = DenseMatrix(n, n, A.m_);
1721 unsigned i, sign = 1;
1722 RCP<const Basic> d;
1723
1724 for (unsigned k = 0; k < n - 1; k++) {
1725 if (is_true(is_zero(*B.m_[k * n + k]))) {
1726 for (i = k + 1; i < n; i++)
1727 if (!is_true(is_zero(*B.m_[i * n + k]))) {
1728 row_exchange_dense(B, i, k);
1729 sign *= -1;
1730 break;
1731 }
1732 if (i == n)
1733 return zero;
1734 }
1735
1736 for (i = k + 1; i < n; i++) {
1737 for (unsigned j = k + 1; j < n; j++) {
1738 d = sub(mul(B.m_[k * n + k], B.m_[i * n + j]),
1739 mul(B.m_[i * n + k], B.m_[k * n + j]));
1740 if (k > 0)
1741 d = div(d, B.m_[(k - 1) * n + k - 1]);
1742 B.m_[i * n + j] = d;
1743 }
1744 }
1745 }
1746
1747 return (sign == 1) ? B.m_[n * n - 1] : mul(minus_one, B.m_[n * n - 1]);
1748 }
1749}

◆ det_berkowitz()

RCP< const Basic > SymEngine::det_berkowitz ( const DenseMatrix A)

Definition at line 1828 of file dense_matrix.cpp.

1829{
1831
1832 berkowitz(A, polys);
1833 DenseMatrix poly = polys[polys.size() - 1];
1834
1835 if (polys.size() % 2 == 1)
1836 return mul(minus_one, poly.get(poly.nrows() - 1, 0));
1837
1838 return poly.get(poly.nrows() - 1, 0);
1839}

◆ diag()

void SymEngine::diag ( DenseMatrix A,
vec_basic v,
int  k 
)

Definition at line 2010 of file dense_matrix.cpp.

2011{
2012 SYMENGINE_ASSERT(v.size() > 0);
2013
2014 unsigned k_ = std::abs(k);
2015
2016 if (k >= 0) {
2017 for (unsigned i = 0; i < A.row_; i++) {
2018 for (unsigned j = 0; j < A.col_; j++) {
2019 if (j != (unsigned)k) {
2020 A.m_[i * A.col_ + j] = zero;
2021 } else {
2022 A.m_[i * A.col_ + j] = v[k - k_];
2023 }
2024 }
2025 k++;
2026 }
2027 } else {
2028 k = -k;
2029
2030 for (unsigned j = 0; j < A.col_; j++) {
2031 for (unsigned i = 0; i < A.row_; i++) {
2032 if (i != (unsigned)k) {
2033 A.m_[i * A.col_ + j] = zero;
2034 } else {
2035 A.m_[i * A.col_ + j] = v[k - k_];
2036 }
2037 }
2038 k++;
2039 }
2040 }
2041}

◆ diagonal_matrix()

RCP< const MatrixExpr > SymEngine::diagonal_matrix ( const vec_basic container)

Definition at line 67 of file diagonal_matrix.cpp.

68{
69 if (is_zero_vec(container)) {
70 return make_rcp<const ZeroMatrix>(integer(container.size()),
71 integer(container.size()));
72 } else if (is_identity_vec(container)) {
73 return make_rcp<const IdentityMatrix>(integer(container.size()));
74 } else {
75 return make_rcp<const DiagonalMatrix>(container);
76 }
77}

◆ diagonal_solve()

void SymEngine::diagonal_solve ( const DenseMatrix A,
const DenseMatrix b,
DenseMatrix x 
)

Definition at line 1130 of file dense_matrix.cpp.

1131{
1132 SYMENGINE_ASSERT(A.row_ == A.col_);
1133 SYMENGINE_ASSERT(x.row_ == A.col_ and x.col_ == b.col_);
1134
1135 const unsigned sys = b.col_;
1136
1137 // No checks are done to see if the diagonal entries are zero
1138 for (unsigned k = 0; k < sys; k++) {
1139 for (unsigned i = 0; i < A.col_; i++) {
1140 x.m_[i * sys + k] = div(b.m_[i * sys + k], A.m_[i * A.col_ + i]);
1141 }
1142 }
1143}

◆ diff() [1/2]

void SymEngine::diff ( const DenseMatrix A,
const RCP< const Symbol > &  x,
DenseMatrix result,
bool  diff_cache 
)

Definition at line 566 of file dense_matrix.cpp.

568{
569 SYMENGINE_ASSERT(A.row_ == result.nrows() and A.col_ == result.ncols());
570#pragma omp parallel for
571 for (unsigned i = 0; i < result.row_; i++) {
572 for (unsigned j = 0; j < result.col_; j++) {
573 result.m_[i * result.col_ + j]
574 = A.m_[i * result.col_ + j]->diff(x, diff_cache);
575 }
576 }
577}

◆ diff() [2/2]

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

Differentiation w.r.t symbols.

Definition at line 803 of file derivative.cpp.

805{
806 DiffVisitor v(x, cache);
807 return v.apply(arg);
808}

◆ diff_mpoly()

template<typename Container , typename Poly >
static RCP< const Basic > SymEngine::diff_mpoly ( const MSymEnginePoly< Container, Poly > &  self,
const RCP< const Symbol > &  x 
)
static

Definition at line 142 of file derivative.cpp.

144{
145 using Dict = typename Container::dict_type;
146 using Vec = typename Container::vec_type;
147 Dict dict;
148
149 if (self.get_vars().find(x) != self.get_vars().end()) {
150 auto i = self.get_vars().begin();
151 unsigned int index = 0;
152 while (!(*i)->__eq__(*x)) {
153 i++;
154 index++;
155 } // find the index of the variable we are differentiating WRT.
156 for (auto bucket : self.get_poly().dict_) {
157 if (bucket.first[index] != 0) {
158 Vec v = bucket.first;
159 v[index]--;
160 dict.insert({v, bucket.second * bucket.first[index]});
161 }
162 }
163 vec_basic v;
164 v.insert(v.begin(), self.get_vars().begin(), self.get_vars().end());
165 return Poly::from_dict(v, std::move(dict));
166 } else {
167 vec_basic vs;
168 vs.insert(vs.begin(), self.get_vars().begin(), self.get_vars().end());
169 return Poly::from_dict(vs, {{}});
170 }
171}

◆ diff_upoly()

template<typename Poly , typename Dict >
static RCP< const Basic > SymEngine::diff_upoly ( const Poly &  self,
const Symbol x 
)
inlinestatic

Definition at line 127 of file derivative.cpp.

128{
129 if (self.get_var()->__eq__(x)) {
130 Dict d;
131 for (auto it = self.begin(); it != self.end(); ++it) {
132 if (it->first != 0)
133 d[it->first - 1] = it->second * it->first;
134 }
135 return Poly::from_dict(self.get_var(), std::move(d));
136 } else {
137 return Poly::from_dict(self.get_var(), {{}});
138 }
139}

◆ diff_upolyflint()

template<typename P >
static RCP< const Basic > SymEngine::diff_upolyflint ( const P &  self,
const Symbol x 
)
inlinestatic

Definition at line 117 of file derivative.cpp.

118{
119 if (self.get_var()->__eq__(x)) {
120 return P::from_container(self.get_var(), self.get_poly().derivative());
121 } else {
122 return P::from_dict(self.get_var(), {{}});
123 }
124}

◆ digamma()

RCP< const Basic > SymEngine::digamma ( const RCP< const Basic > &  x)

Definition at line 3453 of file functions.cpp.

3454{
3455 return polygamma(zero, x);
3456}
RCP< const Basic > polygamma(const RCP< const Basic > &n_, const RCP< const Basic > &x_)
Canonicalize PolyGamma.
Definition: functions.cpp:3397

◆ dirichlet_eta()

RCP< const Basic > SymEngine::dirichlet_eta ( const RCP< const Basic > &  s)

Create a new Dirichlet_eta instance:

Definition at line 2861 of file functions.cpp.

2862{
2863 if (is_a_Number(*s) and down_cast<const Number &>(*s).is_one()) {
2864 return log(i2);
2865 }
2866 RCP<const Basic> z = zeta(s);
2867 if (is_a<Zeta>(*z)) {
2868 return make_rcp<const Dirichlet_eta>(s);
2869 } else {
2870 return mul(sub(one, pow(i2, sub(one, s))), z);
2871 }
2872}

◆ div()

RCP< const Basic > SymEngine::div ( const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
)

Division.

Definition at line 431 of file mul.cpp.

432{
433 if (is_number_and_zero(*b)) {
434 if (is_number_and_zero(*a)) {
435 return Nan;
436 } else {
437 return ComplexInf;
438 }
439 }
440 return mul(a, pow(b, minus_one));
441}
bool is_number_and_zero(const Basic &b)
Definition: number.h:139

◆ divides()

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

Definition at line 161 of file ntheory.cpp.

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

◆ divides_upoly() [1/2]

bool SymEngine::divides_upoly ( const UIntPoly a,
const UIntPoly b,
const Ptr< RCP< const UIntPoly > > &  out 
)

Definition at line 25 of file uintpoly.cpp.

27{
28 if (!(a.get_var()->__eq__(*b.get_var())))
29 throw SymEngineException("Error: variables must agree.");
30
31 auto a_poly = a.get_poly();
32 auto b_poly = b.get_poly();
33 if (a_poly.size() == 0)
34 return false;
35
36 ma