libqalculate-3.20.0
|
The almighty calculator class. More...
#include <Calculator.h>
Public Member Functions | |
Constructor | |
Calculator () | |
Calculator (bool ignore_locale) | |
virtual | ~Calculator () |
Functions for calculating expressions. | |
bool | calculate (MathStructure *mstruct, std::string str, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
MathStructure | calculate (std::string str, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
bool | calculate (MathStructure *mstruct, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, std::string to_str="") |
MathStructure | calculate (const MathStructure &mstruct, const EvaluationOptions &eo=default_user_evaluation_options, std::string to_str="") |
std::string | calculateAndPrint (std::string str, int msecs=10000, const EvaluationOptions &eo=default_user_evaluation_options, const PrintOptions &po=default_print_options) |
std::string | calculateAndPrint (std::string str, int msecs, const EvaluationOptions &eo, const PrintOptions &po, std::string *parsed_expression) |
std::string | calculateAndPrint (std::string str, int msecs, const EvaluationOptions &eo, const PrintOptions &po, AutomaticFractionFormat auto_fraction, AutomaticApproximation auto_approx=AUTOMATIC_APPROXIMATION_OFF, std::string *parsed_expression=NULL, int max_length=-1, bool *result_is_comparison=NULL) |
int | testCondition (std::string expression) |
Functions for printing expressions with the option to set maximum time or abort. | |
std::string | print (const MathStructure &mstruct, int milliseconds=100000, const PrintOptions &po=default_print_options) |
std::string | print (const MathStructure &mstruct, int milliseconds, const PrintOptions &po, bool format, int colorize=0, int tagtype=TAG_TYPE_HTML) |
std::string | printMathStructureTimeOut (const MathStructure &mstruct, int milliseconds=100000, const PrintOptions &op=default_print_options) |
Deprecated: use print() instead. | |
void | startControl (int milliseconds=0) |
void | stopControl (void) |
bool | abort () |
bool | aborted (void) |
bool | isControlled (void) const |
std::string | abortedMessage (void) const |
std::string | timedOutString (void) const |
std::string | logicalORString (void) const |
std::string | logicalANDString (void) const |
void | startPrintControl (int milliseconds=0) |
Deprecated: use startControl() | |
void | abortPrint (void) |
Deprecated: use abort() | |
void | stopPrintControl (void) |
Deprecated: use stopControl() | |
bool | printingAborted (void) |
Deprecated: use aborted() | |
bool | printingControlled (void) const |
Deprecated: use isControlled() | |
std::string | printingAbortedMessage (void) const |
Deprecated: use abortedMessage() | |
Functions for handling of threaded calculations | |
bool | busy () |
void | saveState () |
Deprecated: does nothing. | |
void | restoreState () |
Deprecated: does nothing. | |
void | clearBuffers () |
void | terminateThreads () |
Functions for manipulation of the RPN stack. | |
bool | calculateRPNRegister (size_t index, int msecs, const EvaluationOptions &eo=default_user_evaluation_options) |
bool | calculateRPN (MathOperation op, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
bool | calculateRPN (MathFunction *f, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
bool | calculateRPNBitwiseNot (int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
bool | calculateRPNLogicalNot (int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
MathStructure * | calculateRPN (MathOperation op, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
MathStructure * | calculateRPN (MathFunction *f, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
MathStructure * | calculateRPNBitwiseNot (const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
MathStructure * | calculateRPNLogicalNot (const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL) |
bool | RPNStackEnter (MathStructure *mstruct, int msecs, const EvaluationOptions &eo=default_user_evaluation_options) |
bool | RPNStackEnter (std::string str, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
void | RPNStackEnter (MathStructure *mstruct, bool eval=false, const EvaluationOptions &eo=default_user_evaluation_options) |
void | RPNStackEnter (std::string str, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
bool | setRPNRegister (size_t index, MathStructure *mstruct, int msecs, const EvaluationOptions &eo=default_user_evaluation_options) |
bool | setRPNRegister (size_t index, std::string str, int msecs, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
void | setRPNRegister (size_t index, MathStructure *mstruct, bool eval=false, const EvaluationOptions &eo=default_user_evaluation_options) |
void | setRPNRegister (size_t index, std::string str, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *parsed_struct=NULL, MathStructure *to_struct=NULL, bool make_to_division=true) |
void | deleteRPNRegister (size_t index) |
MathStructure * | getRPNRegister (size_t index=1) const |
size_t | RPNStackSize () const |
void | clearRPNStack () |
void | moveRPNRegister (size_t old_index, size_t new_index) |
void | moveRPNRegisterUp (size_t index) |
void | moveRPNRegisterDown (size_t index) |
Functions for expression parsing. | |
std::string | localizeExpression (std::string str, const ParseOptions &po=default_parse_options) const |
std::string | unlocalizeExpression (std::string str, const ParseOptions &po=default_parse_options) const |
bool | separateToExpression (std::string &str, std::string &to_str, const EvaluationOptions &eo, bool keep_modifiers=false, bool allow_empty_from=false) const |
bool | hasToExpression (const std::string &str, bool allow_empty_from=false) const |
bool | hasToExpression (const std::string &str, bool allow_empty_from, const EvaluationOptions &eo) const |
bool | separateWhereExpression (std::string &str, std::string &where_str, const EvaluationOptions &eo) const |
Split an expression string after and before " where ". | |
bool | hasWhereExpression (const std::string &str, const EvaluationOptions &eo) const |
std::string | parseComments (std::string &str, const ParseOptions &po=default_parse_options, bool *double_tag=NULL) |
void | parseSigns (std::string &str, bool convert_to_internal_representation=false) const |
MathStructure | parse (std::string str, const ParseOptions &po=default_parse_options) |
void | parse (MathStructure *mstruct, std::string str, const ParseOptions &po=default_parse_options) |
bool | parseNumber (MathStructure *mstruct, std::string str, const ParseOptions &po=default_parse_options) |
bool | parseOperators (MathStructure *mstruct, std::string str, const ParseOptions &po=default_parse_options) |
bool | parseAdd (std::string &str, MathStructure *mstruct, const ParseOptions &po, MathOperation s, bool append=true) |
bool | parseAdd (std::string &str, MathStructure *mstruct, const ParseOptions &po) |
Functions converting epxressions between units. | |
MathStructure | convert (const MathStructure &mstruct, std::string composite_, const EvaluationOptions &eo=default_user_evaluation_options, MathStructure *units=NULL) |
MathStructure | convert (const MathStructure &mstruct, Unit *to_unit, const EvaluationOptions &eo=default_user_evaluation_options, bool always_convert=true, bool convert_to_mixed_units=true) |
MathStructure | convert (const MathStructure &mstruct, KnownVariable *to_var, const EvaluationOptions &eo=default_user_evaluation_options) |
MathStructure | convert (double value, Unit *from_unit, Unit *to_unit, const EvaluationOptions &eo=default_user_evaluation_options) |
MathStructure | convert (std::string str, Unit *from_unit, Unit *to_unit, int milliseconds, const EvaluationOptions &eo=default_user_evaluation_options) |
MathStructure | convertTimeOut (std::string str, Unit *from_unit, Unit *to_unit, int milliseconds, const EvaluationOptions &eo=default_user_evaluation_options) |
MathStructure | convert (std::string str, Unit *from_unit, Unit *to_unit, const EvaluationOptions &eo=default_user_evaluation_options) |
MathStructure | convertToBaseUnits (const MathStructure &mstruct, const EvaluationOptions &eo=default_user_evaluation_options) |
Unit * | getBestUnit (Unit *u, bool allow_only_div=false, bool convert_to_local_currency=true) |
Unit * | getOptimalUnit (Unit *u, bool allow_only_div=false, bool convert_to_local_currency=true) |
MathStructure | convertToBestUnit (const MathStructure &mstruct, const EvaluationOptions &eo=default_user_evaluation_options, bool convert_to_si_units=true) |
MathStructure | convertToOptimalUnit (const MathStructure &mstruct, const EvaluationOptions &eo=default_user_evaluation_options, bool convert_to_si_units=true) |
MathStructure | convertToCompositeUnit (const MathStructure &mstruct, CompositeUnit *cu, const EvaluationOptions &eo=default_user_evaluation_options, bool always_convert=true) |
MathStructure | convertToMixedUnits (const MathStructure &mstruct, const EvaluationOptions &eo=default_user_evaluation_options) |
void | setTemperatureCalculationMode (TemperatureCalculationMode temperature_calculation_mode) |
TemperatureCalculationMode | getTemperatureCalculationMode () const |
Unit * | findMatchingUnit (const MathStructure &mstruct) |
Functions for default assumptions for unknown variables and symbols | |
void | setDefaultAssumptions (Assumptions *ass) |
Assumptions * | defaultAssumptions () |
Functions for retrieval of angle units | |
Unit * | getGraUnit () |
Unit * | getRadUnit () |
Unit * | getDegUnit () |
Functions for finding a suitable prefix. | |
DecimalPrefix * | getExactDecimalPrefix (int exp10, int exp=1) const |
BinaryPrefix * | getExactBinaryPrefix (int exp2, int exp=1) const |
Prefix * | getExactPrefix (const Number &o, int exp=1) const |
DecimalPrefix * | getNearestDecimalPrefix (int exp10, int exp=1) const |
DecimalPrefix * | getOptimalDecimalPrefix (int exp10, int exp=1, bool all_prefixes=true) const |
DecimalPrefix * | getOptimalDecimalPrefix (const Number &exp10, const Number &exp, bool all_prefixes=true) const |
BinaryPrefix * | getNearestBinaryPrefix (int exp2, int exp=1) const |
BinaryPrefix * | getOptimalBinaryPrefix (int exp2, int exp=1) const |
BinaryPrefix * | getOptimalBinaryPrefix (const Number &exp2, const Number &exp) const |
int | usesBinaryPrefixes () const |
void | useBinaryPrefixes (int use_binary_prefixes) |
Prefix * | addPrefix (Prefix *p) |
void | prefixNameChanged (Prefix *p, bool new_item=false) |
Functions for managing functions, variables, units, prefixes and data sets. | |
void | expressionItemActivated (ExpressionItem *item) |
void | expressionItemDeactivated (ExpressionItem *item) |
void | expressionItemDeleted (ExpressionItem *item) |
void | nameChanged (ExpressionItem *item, bool new_item=false) |
void | deleteName (std::string name_, ExpressionItem *object=NULL) |
void | deleteUnitName (std::string name_, Unit *object=NULL) |
Unit * | addUnit (Unit *u, bool force=true, bool check_names=true) |
void | delPrefixUFV (Prefix *object) |
void | delUFV (ExpressionItem *object) |
bool | hasVariable (Variable *v) |
bool | hasUnit (Unit *u) |
bool | hasFunction (MathFunction *f) |
bool | stillHasVariable (Variable *v) |
bool | stillHasUnit (Unit *u) |
bool | stillHasFunction (MathFunction *f) |
void | saveFunctionCalled () |
bool | checkSaveFunctionCalled () |
ExpressionItem * | getActiveExpressionItem (std::string name, ExpressionItem *item=NULL) |
ExpressionItem * | getInactiveExpressionItem (std::string name, ExpressionItem *item=NULL) |
ExpressionItem * | getActiveExpressionItem (ExpressionItem *item) |
ExpressionItem * | getExpressionItem (std::string name, ExpressionItem *item=NULL) |
Unit * | getUnit (std::string name_) |
Unit * | getUnitById (int id) const |
Unit * | getActiveUnit (std::string name_) |
Unit * | getCompositeUnit (std::string internal_name_) |
Unit * | getLocalCurrency () |
void | setLocalCurrency (Unit *u) |
Prefix * | getPrefix (size_t index) const |
Prefix * | getPrefix (std::string name_) const |
Prefix * | getDecimalNullPrefix () const |
Prefix * | getBinaryNullPrefix () const |
Variable * | addVariable (Variable *v, bool force=true, bool check_names=true) |
void | variableNameChanged (Variable *v, bool new_item=false) |
void | functionNameChanged (MathFunction *f, bool new_item=false) |
void | unitNameChanged (Unit *u, bool new_item=false) |
Variable * | getVariable (std::string name_) |
Variable * | getVariableById (int id) const |
Variable * | getActiveVariable (std::string name_) |
ExpressionItem * | addExpressionItem (ExpressionItem *item, bool force=true) |
MathFunction * | addFunction (MathFunction *f, bool force=true, bool check_names=true) |
DataSet * | addDataSet (DataSet *dc, bool force=true, bool check_names=true) |
DataSet * | getDataSet (size_t index) |
DataSet * | getDataSet (std::string name) |
MathFunction * | getFunction (std::string name_) |
MathFunction * | getFunctionById (int id) const |
MathFunction * | getActiveFunction (std::string name_) |
Variable * | getVariable (size_t index) const |
Unit * | getUnit (size_t index) const |
MathFunction * | getFunction (size_t index) const |
bool | unitIsUsedByOtherUnits (const Unit *u) const |
Functions for handling of builtin expression items | |
void | resetVariables () |
void | resetFunctions () |
void | resetUnits () |
void | reset () |
void | addBuiltinVariables () |
void | addBuiltinFunctions () |
void | addBuiltinUnits () |
void | setVariableUnitsEnabled (bool enable_variable_units=true) |
bool | variableUnitsEnabled () const |
Functions for testing validity of functions, variable and unit names. | |
bool | variableNameIsValid (const std::string &name_) |
bool | variableNameIsValid (const char *name_) |
bool | variableNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs) |
bool | variableNameIsValid (const std::string &name_, int version_numbers[3], bool is_user_defs) |
std::string | convertToValidVariableName (std::string name_) |
bool | functionNameIsValid (const std::string &name_) |
bool | functionNameIsValid (const char *name_) |
bool | functionNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs) |
bool | functionNameIsValid (const std::string &name_, int version_numbers[3], bool is_user_defs) |
std::string | convertToValidFunctionName (std::string name_) |
bool | unitNameIsValid (const std::string &name_) |
bool | unitNameIsValid (const char *name_) |
bool | unitNameIsValid (const char *name_, int version_numbers[3], bool is_user_defs) |
bool | unitNameIsValid (const std::string &name_, int version_numbers[3], bool is_user_defs) |
bool | utf8_pos_is_valid_in_name (char *pos) |
std::string | convertToValidUnitName (std::string name_) |
bool | nameTaken (std::string name, ExpressionItem *object=NULL) |
bool | variableNameTaken (std::string name, Variable *object=NULL) |
bool | unitNameTaken (std::string name, Unit *object=NULL) |
bool | functionNameTaken (std::string name, MathFunction *object=NULL) |
std::string | getName (std::string name="", ExpressionItem *object=NULL, bool force=false, bool always_append=false) |
Functions for message handling. | |
void | error (bool critical, int message_category, const char *TEMPLATE,...) |
void | error (bool critical, const char *TEMPLATE,...) |
void | message (MessageType mtype, int message_category, const char *TEMPLATE,...) |
void | message (MessageType mtype, const char *TEMPLATE,...) |
void | message (MessageType mtype, int message_category, const char *TEMPLATE, va_list ap) |
CalculatorMessage * | message () |
CalculatorMessage * | nextMessage () |
void | clearMessages () |
bool | showArgumentErrors () const |
void | beginTemporaryStopMessages () |
int | endTemporaryStopMessages (int *message_count=NULL, int *warning_count=NULL, int release_messages_if_no_equal_or_greater_than_message_type=-1) |
void | endTemporaryStopMessages (bool release_messages, std::vector< CalculatorMessage > *blocked_messages=NULL) |
void | addMessages (std::vector< CalculatorMessage > *message_vector) |
const PrintOptions & | messagePrintOptions () const |
void | setMessagePrintOptions (const PrintOptions &po) |
void | cleanMessages (const MathStructure &mstruct, size_t first_message=1) |
Functions for loading and saving definitions (variables, functions, units, etc.). | |
bool | loadGlobalDefinitions () |
bool | loadGlobalDefinitions (std::string filename) |
bool | loadGlobalPrefixes () |
bool | loadGlobalCurrencies () |
bool | loadGlobalUnits () |
bool | loadGlobalVariables () |
bool | loadGlobalFunctions () |
bool | loadGlobalDataSets () |
bool | loadLocalDefinitions () |
int | loadDefinitions (const char *file_name, bool is_user_defs=true, bool check_duplicates_of_global=false) |
bool | saveDefinitions () |
int | saveDataObjects () |
int | savePrefixes (const char *file_name, bool save_global=false) |
std::string | temporaryCategory (void) const |
int | saveVariables (const char *file_name, bool save_global=false) |
int | saveUnits (const char *file_name, bool save_global=false) |
int | saveFunctions (const char *file_name, bool save_global=false) |
int | saveDataSets (const char *file_name, bool save_global=false) |
Functions for CSV file import/export. | |
bool | importCSV (MathStructure &mstruct, const char *file_name, int first_row=1, std::string delimiter=",", std::vector< std::string > *headers=NULL) |
bool | importCSV (const char *file_name, int first_row=1, bool headers=true, std::string delimiter=",", bool to_matrix=false, std::string name="", std::string title="", std::string category="") |
bool | exportCSV (const MathStructure &mstruct, const char *file_name, std::string delimiter=",") |
Functions for exchange rates. | |
bool | canFetch () |
bool | hasGVFS () |
Deprecated: gvfs is not needed anymore. | |
bool | hasGnomeVFS () |
Deprecated: gvfs is not needed anymore. | |
bool | loadExchangeRates () |
std::string | getExchangeRatesFileName (int index=1) |
std::string | getExchangeRatesUrl (int index=1) |
time_t | getExchangeRatesTime (int index=-1) |
bool | fetchExchangeRates (int seconds, std::string wget_args) |
Deprecated: wget arguments are not used. | |
bool | fetchExchangeRates (int seconds=15, int n=-1) |
bool | checkExchangeRatesDate (unsigned int n_days=7, bool force_check=false, bool send_warning=false, int n=-1) |
void | setExchangeRatesWarningEnabled (bool enable) |
Enable or disable old exchange rates warning (initial state is true). | |
bool | exchangeRatesWarningEnabled () const |
int | exchangeRatesUsed () const |
Check if exchange rates has been used since resetExchangeRatesUsed() was last called. | |
void | resetExchangeRatesUsed () |
void | setExchangeRatesUsed (int index) |
For internal use, called by currency units. | |
Functions for plotting | |
bool | canPlot () |
MathStructure | expressionToPlotVector (std::string expression, const MathStructure &min, const MathStructure &max, int steps, MathStructure *x_vector=NULL, std::string x_var="\\x", const ParseOptions &po=default_parse_options, int msecs=5000) |
MathStructure | expressionToPlotVector (std::string expression, float min, float max, int steps, MathStructure *x_vector=NULL, std::string x_var="\\x", const ParseOptions &po=default_parse_options, int msecs=5000) |
MathStructure | expressionToPlotVector (std::string expression, const MathStructure &min, const MathStructure &max, const MathStructure &step, MathStructure *x_vector=NULL, std::string x_var="\\x", const ParseOptions &po=default_parse_options, int msecs=5000) |
MathStructure | expressionToPlotVector (std::string expression, float min, float max, float step, MathStructure *x_vector=NULL, std::string x_var="\\x", const ParseOptions &po=default_parse_options, int msecs=5000) |
MathStructure | expressionToPlotVector (std::string expression, const MathStructure &x_vector, std::string x_var="\\x", const ParseOptions &po=default_parse_options, int msecs=5000) |
bool | plotVectors (PlotParameters *param, const std::vector< MathStructure > &y_vectors, const std::vector< MathStructure > &x_vectors, std::vector< PlotDataParameters * > &pdps, bool persistent=false, int msecs=5000) |
bool | invokeGnuplot (std::string commands, std::string commandline_extra="", bool persistent=false) |
bool | closeGnuplot () |
bool | gnuplotOpen () |
Functions for global precision | |
void | setPrecision (int precision=DEFAULT_PRECISION) |
int | getPrecision () const |
void | useIntervalArithmetic (bool use_interval_arithmetic=true) |
bool | usesIntervalArithmetic () const |
void | beginTemporaryStopIntervalArithmetic () |
void | endTemporaryStopIntervalArithmetic () |
void | beginTemporaryEnableIntervalArithmetic () |
void | endTemporaryEnableIntervalArithmetic () |
void | setCustomInputBase (Number nr) |
void | setCustomOutputBase (Number nr) |
const Number & | customInputBase () const |
const Number & | customOutputBase () const |
Functions for localization | |
const std::string & | getDecimalPoint () const |
const std::string & | getComma () const |
void | setLocale () |
void | setIgnoreLocale () |
Deprecated: use pass true to constructor instead. | |
bool | getIgnoreLocale () |
void | useDecimalComma () |
void | useDecimalPoint (bool comma_as_separator=false) |
void | unsetLocale () |
std::string | localToString (bool include_spaces=true) const |
std::string | localWhereString () const |
Functions adding alternative symbols for operators and such | |
void | addStringAlternative (std::string replacement, std::string standard) |
bool | delStringAlternative (std::string replacement, std::string standard) |
void | addDefaultStringAlternative (std::string replacement, std::string standard) |
bool | delDefaultStringAlternative (std::string replacement, std::string standard) |
Functions for storing values with associated identifiers | |
size_t | addId (MathStructure *mstruct, bool persistent=false) |
size_t | parseAddId (MathFunction *f, const std::string &str, const ParseOptions &po, bool persistent=false) |
size_t | parseAddIdAppend (MathFunction *f, const MathStructure &append_mstruct, const std::string &str, const ParseOptions &po, bool persistent=false) |
size_t | parseAddVectorId (const std::string &str, const ParseOptions &po, bool persistent=false) |
MathStructure * | getId (size_t id) |
void | delId (size_t id) |
Public Attributes | |
KnownVariable * | v_pi |
KnownVariable * | v_e |
KnownVariable * | v_euler |
KnownVariable * | v_catalan |
KnownVariable * | v_i |
KnownVariable * | v_pinf |
KnownVariable * | v_minf |
KnownVariable * | v_undef |
KnownVariable * | v_precision |
KnownVariable * | v_percent |
KnownVariable * | v_permille |
KnownVariable * | v_permyriad |
KnownVariable * | v_today |
KnownVariable * | v_yesterday |
KnownVariable * | v_tomorrow |
KnownVariable * | v_now |
UnknownVariable * | v_x |
UnknownVariable * | v_y |
UnknownVariable * | v_z |
UnknownVariable * | v_C |
UnknownVariable * | v_n |
MathFunction * | f_vector |
MathFunction * | f_sort |
MathFunction * | f_rank |
MathFunction * | f_limits |
MathFunction * | f_component |
MathFunction * | f_dimension |
MathFunction * | f_merge_vectors |
MathFunction * | f_matrix |
MathFunction * | f_matrix_to_vector |
MathFunction * | f_area |
MathFunction * | f_rows |
MathFunction * | f_columns |
MathFunction * | f_row |
MathFunction * | f_column |
MathFunction * | f_elements |
MathFunction * | f_element |
MathFunction * | f_transpose |
MathFunction * | f_identity |
MathFunction * | f_determinant |
MathFunction * | f_permanent |
MathFunction * | f_adjoint |
MathFunction * | f_cofactor |
MathFunction * | f_inverse |
MathFunction * | f_magnitude |
MathFunction * | f_hadamard |
MathFunction * | f_entrywise |
MathFunction * | f_factorial |
MathFunction * | f_factorial2 |
MathFunction * | f_multifactorial |
MathFunction * | f_binomial |
MathFunction * | f_xor |
MathFunction * | f_bitxor |
MathFunction * | f_even |
MathFunction * | f_odd |
MathFunction * | f_shift |
MathFunction * | f_bitcmp |
MathFunction * | f_abs |
MathFunction * | f_gcd |
MathFunction * | f_lcm |
MathFunction * | f_signum |
MathFunction * | f_heaviside |
MathFunction * | f_dirac |
MathFunction * | f_round |
MathFunction * | f_floor |
MathFunction * | f_ceil |
MathFunction * | f_trunc |
MathFunction * | f_int |
MathFunction * | f_frac |
MathFunction * | f_rem |
MathFunction * | f_mod |
MathFunction * | f_polynomial_unit |
MathFunction * | f_polynomial_primpart |
MathFunction * | f_polynomial_content |
MathFunction * | f_coeff |
MathFunction * | f_lcoeff |
MathFunction * | f_tcoeff |
MathFunction * | f_degree |
MathFunction * | f_ldegree |
MathFunction * | f_re |
MathFunction * | f_im |
MathFunction * | f_arg |
MathFunction * | f_numerator |
MathFunction * | f_denominator |
MathFunction * | f_interval |
MathFunction * | f_uncertainty |
MathFunction * | f_sqrt |
MathFunction * | f_cbrt |
MathFunction * | f_root |
MathFunction * | f_sq |
MathFunction * | f_exp |
MathFunction * | f_ln |
MathFunction * | f_logn |
MathFunction * | f_lambert_w |
MathFunction * | f_sin |
MathFunction * | f_cos |
MathFunction * | f_tan |
MathFunction * | f_asin |
MathFunction * | f_acos |
MathFunction * | f_atan |
MathFunction * | f_sinh |
MathFunction * | f_cosh |
MathFunction * | f_tanh |
MathFunction * | f_asinh |
MathFunction * | f_acosh |
MathFunction * | f_atanh |
MathFunction * | f_atan2 |
MathFunction * | f_sinc |
MathFunction * | f_radians_to_default_angle_unit |
MathFunction * | f_zeta |
MathFunction * | f_gamma |
MathFunction * | f_digamma |
MathFunction * | f_beta |
MathFunction * | f_airy |
MathFunction * | f_besselj |
MathFunction * | f_bessely |
MathFunction * | f_erf |
MathFunction * | f_erfc |
MathFunction * | f_total |
MathFunction * | f_percentile |
MathFunction * | f_min |
MathFunction * | f_max |
MathFunction * | f_mode |
MathFunction * | f_rand |
MathFunction * | f_date |
MathFunction * | f_datetime |
MathFunction * | f_timevalue |
MathFunction * | f_timestamp |
MathFunction * | f_stamptodate |
MathFunction * | f_days |
MathFunction * | f_yearfrac |
MathFunction * | f_week |
MathFunction * | f_weekday |
MathFunction * | f_month |
MathFunction * | f_day |
MathFunction * | f_year |
MathFunction * | f_yearday |
MathFunction * | f_time |
MathFunction * | f_add_days |
MathFunction * | f_add_months |
MathFunction * | f_add_years |
MathFunction * | f_lunarphase |
MathFunction * | f_nextlunarphase |
MathFunction * | f_bin |
MathFunction * | f_oct |
MathFunction * | f_hex |
MathFunction * | f_base |
MathFunction * | f_roman |
MathFunction * | f_ascii |
MathFunction * | f_char |
MathFunction * | f_length |
MathFunction * | f_concatenate |
MathFunction * | f_replace |
MathFunction * | f_stripunits |
MathFunction * | f_genvector |
MathFunction * | f_for |
MathFunction * | f_sum |
MathFunction * | f_product |
MathFunction * | f_process |
MathFunction * | f_process_matrix |
MathFunction * | f_csum |
MathFunction * | f_if |
MathFunction * | f_is_number |
MathFunction * | f_is_real |
MathFunction * | f_is_rational |
MathFunction * | f_is_integer |
MathFunction * | f_represents_number |
MathFunction * | f_represents_real |
MathFunction * | f_represents_rational |
MathFunction * | f_represents_integer |
MathFunction * | f_function |
MathFunction * | f_select |
MathFunction * | f_diff |
MathFunction * | f_integrate |
MathFunction * | f_solve |
MathFunction * | f_multisolve |
MathFunction * | f_dsolve |
MathFunction * | f_limit |
MathFunction * | f_li |
MathFunction * | f_Li |
MathFunction * | f_Ei |
MathFunction * | f_Si |
MathFunction * | f_Ci |
MathFunction * | f_Shi |
MathFunction * | f_Chi |
MathFunction * | f_igamma |
MathFunction * | f_error |
MathFunction * | f_warning |
MathFunction * | f_message |
MathFunction * | f_save |
MathFunction * | f_load |
MathFunction * | f_export |
MathFunction * | f_title |
MathFunction * | f_register |
MathFunction * | f_stack |
MathFunction * | f_plot |
Unit * | u_rad |
Unit * | u_gra |
Unit * | u_deg |
Unit * | u_euro |
Unit * | u_btc |
Unit * | u_second |
Unit * | u_minute |
Unit * | u_hour |
Unit * | u_year |
Unit * | u_month |
Unit * | u_day |
DecimalPrefix * | decimal_null_prefix |
BinaryPrefix * | binary_null_prefix |
bool | place_currency_code_before |
bool | place_currency_sign_before |
bool | place_currency_code_before_negative |
bool | place_currency_sign_before_negative |
bool | default_dot_as_separator |
std::string | local_digit_group_separator |
std::string | local_digit_group_format |
bool | b_busy |
std::string | expression_to_calculate |
EvaluationOptions | tmp_evaluationoptions |
MathStructure * | tmp_parsedstruct |
MathStructure * | tmp_tostruct |
MathStructure * | tmp_rpn_mstruct |
bool | tmp_maketodivision |
int | tmp_proc_command |
int | tmp_proc_registers |
size_t | tmp_rpnindex |
PrintOptions | save_printoptions |
PrintOptions | message_printoptions |
std::vector< Variable * > | variables |
std::vector< MathFunction * > | functions |
std::vector< Unit * > | units |
std::vector< Prefix * > | prefixes |
std::vector< DecimalPrefix * > | decimal_prefixes |
std::vector< BinaryPrefix * > | binary_prefixes |
Protected Member Functions | |
bool | calculateRPN (MathStructure *mstruct, int command, size_t index, int msecs, const EvaluationOptions &eo, int function_arguments=0) |
bool | calculateRPN (std::string str, int command, size_t index, int msecs, const EvaluationOptions &eo, MathStructure *parsed_struct, MathStructure *to_struct, bool make_to_division, int function_arguments=0) |
Protected Attributes | |
std::vector< CalculatorMessage > | messages |
int | ianglemode |
int | i_precision |
bool | b_interval |
int | i_stop_interval |
int | i_start_interval |
char | vbuffer [200] |
std::vector< void * > | ufvl |
std::vector< char > | ufvl_t |
std::vector< size_t > | ufvl_i |
std::vector< void * > | ufv [4][UFV_LENGTHS] |
std::vector< size_t > | ufv_i [4][UFV_LENGTHS] |
std::vector< DataSet * > | data_sets |
class Calculator_p * | priv |
std::vector< std::string > | signs |
std::vector< std::string > | real_signs |
std::vector< std::string > | default_signs |
std::vector< std::string > | default_real_signs |
bool | b_ignore_locale |
char * | saved_locale |
int | disable_errors_ref |
std::vector< int > | stopped_errors_count |
std::vector< int > | stopped_warnings_count |
std::vector< int > | stopped_messages_count |
std::vector< std::vector< CalculatorMessage > > | stopped_messages |
Thread * | calculate_thread |
std::string | NAME_NUMBER_PRE_S |
std::string | NAME_NUMBER_PRE_STR |
std::string | DOT_STR |
std::string | DOT_S |
std::string | COMMA_S |
std::string | COMMA_STR |
std::string | ILLEGAL_IN_NAMES |
std::string | ILLEGAL_IN_UNITNAMES |
std::string | ILLEGAL_IN_NAMES_MINUS_SPACE_STR |
bool | b_argument_errors |
int | current_stage |
time_t | exchange_rates_time [3] |
time_t | exchange_rates_check_time [3] |
int | b_exchange_rates_used |
bool | b_exchange_rates_warning_enabled |
bool | b_gnuplot_open |
std::string | gnuplot_cmdline |
FILE * | gnuplot_pipe |
bool | local_to |
Assumptions * | default_assumptions |
std::vector< Variable * > | deleted_variables |
std::vector< MathFunction * > | deleted_functions |
std::vector< Unit * > | deleted_units |
bool | b_var_units |
bool | b_save_called |
int | i_timeout |
struct timeval | t_end |
int | i_aborted |
bool | b_controlled |
std::string | per_str |
std::string | times_str |
std::string | plus_str |
std::string | minus_str |
std::string | and_str |
std::string | AND_str |
std::string | or_str |
std::string | OR_str |
std::string | XOR_str |
size_t | per_str_len |
size_t | times_str_len |
size_t | plus_str_len |
size_t | minus_str_len |
size_t | and_str_len |
size_t | AND_str_len |
size_t | or_str_len |
size_t | OR_str_len |
size_t | XOR_str_len |
std::vector< MathStructure * > | rpn_stack |
The almighty calculator class.
The calculator class is responsible for loading functions, variables and units, and keeping track of them, as well as parsing expressions and much more. A calculator object must be created before any other Qalculate! class is used. There should never be more than one calculator object, accessed with CALCULATOR.
A simple application using libqalculate need only create a calculator object, perhaps load definitions (functions, variables, units, etc.) and use the calculate function as follows:
bool Calculator::abort | ( | ) |
Abort formatting, printing or evaluation (after startControl() has been called). This function will normally be called from a thread that checks for user input or other conditions.
void Calculator::addBuiltinFunctions | ( | ) |
Adds builtin functions. Called automatically when the calculator is created.
void Calculator::addBuiltinUnits | ( | ) |
Adds builtin units. Called automatically when the calculator is created.
void Calculator::addBuiltinVariables | ( | ) |
Adds builtin variables. Called automatically when the calculator is created.
size_t Calculator::addId | ( | MathStructure * | mstruct, |
bool | persistent = false |
||
) |
Stores a value with an associated id. Mainly for internal use.
mstruct | The value to store. |
persistent | If false the values will be removed from storage when retrieved with getId(). |
bool Calculator::busy | ( | ) |
Returns true if the calculate or print thread is busy.
MathStructure Calculator::calculate | ( | const MathStructure & | mstruct, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
std::string | to_str = "" |
||
) |
Calculates a parsed value.
mstruct | Parsed value to evaluate. |
eo | Options for the evaluation of the expression. |
to_str | "to" expression for conversion. |
bool Calculator::calculate | ( | MathStructure * | mstruct, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
std::string | to_str = "" |
||
) |
Calculates a parsed value. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
[out] | mstruct | Parsed value to evaluate and fill with the result. |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation of the expression. | |
to_str | "to" expression for conversion. |
bool Calculator::calculate | ( | MathStructure * | mstruct, |
std::string | str, | ||
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL , |
||
MathStructure * | to_struct = NULL , |
||
bool | make_to_division = true |
||
) |
Calculates an expression. The expression should be unlocalized first with unlocalizeExpression(). This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
[out] | mstruct | Math structure to fill with the result. |
str | Expression. | |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the result of the parsing of the expression. |
[out] | to_struct | NULL or a math structure to fill with unit expression parsed after "to". If expression does not contain a "to" string, and to_struct is a unit or a symbol (a unit expression string), to_struct will be used instead. |
make_to_division | If true, the expression after "to" will be interpreted as a unit epxression to convert the result to. |
MathStructure Calculator::calculate | ( | std::string | str, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL , |
||
MathStructure * | to_struct = NULL , |
||
bool | make_to_division = true |
||
) |
Calculates an expression. The expression should be unlocalized first with unlocalizeExpression().
str | Expression. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the result of the parsing of the expression. |
[out] | to_struct | NULL or a math structure to fill with unit expression parsed after "to". If expression does not contain a "to" string, and to_struct is a unit or a symbol (a unit expression string), to_struct will be used instead. |
make_to_division | If true, the expression after "to" will be interpreted as a unit epxression to convert the result to. |
std::string Calculator::calculateAndPrint | ( | std::string | str, |
int | msecs = 10000 , |
||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
const PrintOptions & | po = default_print_options |
||
) |
Calculates an expression.and outputs the result to a text string. The expression should be unlocalized first with unlocalizeExpression().
Unlike other functions for expression evaluation this function handles ending "to"-commmands, in addition to unit conversion, such "to hexadecimal" or to "fractions", similar to the qalc application.
str | Expression. |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. |
eo | Options for the evaluation and parsing of the expression. |
po | Result formatting options. |
MathStructure* Calculator::calculateRPN | ( | MathFunction * | f, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies a mathematical operation to the first value on the RPN stack. The value is set as the first argument of the function. If no register is available, then zero is added.
f | Mathematical function. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
bool Calculator::calculateRPN | ( | MathFunction * | f, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies a mathematical operation to the first value on the RPN stack. The value is set as the first argument of the function. If no register is available, then zero is added. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
f | Mathematical function. | |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
MathStructure* Calculator::calculateRPN | ( | MathOperation | op, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies a mathematical operation to the first and second value on the RPN stack. The the second value is changed with input from the first value. For example, with OPERATION_SUBTRACT the first value is subtracted from the second. The first value on the stack is removed. If not enough registers is available, then zeros are added.
op | Operation. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
bool Calculator::calculateRPN | ( | MathOperation | op, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies a mathematical operation to the first and second value on the RPN stack. The the second value is changed with input from the first value. For example, with OPERATION_SUBTRACT the first value is subtracted from the second. The first value on the stack is removed. If not enough registers is available, then zeros are added. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
op | Operation. | |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
MathStructure* Calculator::calculateRPNBitwiseNot | ( | const EvaluationOptions & | eo = default_user_evaluation_options , |
MathStructure * | parsed_struct = NULL |
||
) |
Applies bitwise not to the first value on the RPN stack. If no register is available, then zero is added.
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
bool Calculator::calculateRPNBitwiseNot | ( | int | msecs, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies bitwise not to the first value on the RPN stack. If no register is available, then zero is added. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
MathStructure* Calculator::calculateRPNLogicalNot | ( | const EvaluationOptions & | eo = default_user_evaluation_options , |
MathStructure * | parsed_struct = NULL |
||
) |
Applies logical not to the first value on the RPN stack. If no register is available, then zero is added.
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
bool Calculator::calculateRPNLogicalNot | ( | int | msecs, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL |
||
) |
Applies logical not to the first value on the RPN stack. If no register is available, then zero is added. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the unevaluated result. |
bool Calculator::calculateRPNRegister | ( | size_t | index, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options |
||
) |
Evaluates a value on the RPN stack. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
index | Index, starting at 1, on the RPN stack. |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. |
eo | Options for the evaluation and parsing of the expression. |
bool Calculator::canFetch | ( | ) |
Checks if able to downloading exchange rates from the Internet (using libcurl).
bool Calculator::canPlot | ( | ) |
Checks if gnuplot is available.
bool Calculator::checkExchangeRatesDate | ( | unsigned int | n_days = 7 , |
bool | force_check = false , |
||
bool | send_warning = false , |
||
int | n = -1 |
||
) |
Check age of exchange rates on local disc.
n_days | How old in days exchange rates may be before exchange rates need updating |
force_check | If exchange rates date should be checked again even if found outdated within n_days before |
send_warning | If the standard exchange rates warning should be sent. |
void Calculator::clearBuffers | ( | ) |
Clears all stored values. Used internally after aborted calculation.
void Calculator::clearMessages | ( | ) |
Clear the message queue.
MathStructure Calculator::convert | ( | const MathStructure & | mstruct, |
std::string | composite_, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | units = NULL |
||
) |
Converts to a unit expression. The converted value is evaluated.
mstruct | The value to convert. | |
composite_ | Unit expression. | |
eo | Evaluation options. | |
[out] | units | NULL or a math structure to fill with the parsed unit expression(or set to undefined if no units were found). |
MathStructure Calculator::convert | ( | const MathStructure & | mstruct, |
Unit * | to_unit, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
bool | always_convert = true , |
||
bool | convert_to_mixed_units = true |
||
) |
Converts to a unit. The converted value is evaluated.
mstruct | The value to convert. |
composite_ | Unit to convert to. |
eo | Evaluation options. |
always_convert | ... |
MathStructure Calculator::convertTimeOut | ( | std::string | str, |
Unit * | from_unit, | ||
Unit * | to_unit, | ||
int | milliseconds, | ||
const EvaluationOptions & | eo = default_user_evaluation_options |
||
) |
Depecated: use convert()
MathStructure Calculator::convertToBestUnit | ( | const MathStructure & | mstruct, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
bool | convert_to_si_units = true |
||
) |
Deprecated: use convertToOptimalUnit()
Assumptions* Calculator::defaultAssumptions | ( | ) |
Returns the default assumptions for objects without own assumptions (unknown variables and symbols).
void Calculator::delId | ( | size_t | id | ) |
Removes and unreferences (value->unref() will be called) a value from storage. Mainly for internal use.
id | Storage id. |
bool Calculator::fetchExchangeRates | ( | int | seconds = 15 , |
int | n = -1 |
||
) |
Download current exchange rates from the Internet to local disc with default wget arguments.
seconds | Maximum time for donwload try |
Unit* Calculator::findMatchingUnit | ( | const MathStructure & | mstruct | ) |
Used by the UI to find unit category for a mathematical expression.
Unit* Calculator::getBestUnit | ( | Unit * | u, |
bool | allow_only_div = false , |
||
bool | convert_to_local_currency = true |
||
) |
Deprecated: use getOptimalUnit()
const std::string& Calculator::getComma | ( | ) | const |
Returns the preferred comma character for separating arguments.
const std::string& Calculator::getDecimalPoint | ( | ) | const |
Returns the preferred decimal point character.
Unit* Calculator::getDegUnit | ( | ) |
Returns the degrees unit.
BinaryPrefix* Calculator::getExactBinaryPrefix | ( | int | exp2, |
int | exp = 1 |
||
) | const |
Returns a binary prefix with exactly the provided value, that fulfils the condition prefix->exponent(exp) == exp2.
exp2 | Base-2 exponent of the requested prefix. |
exp | The exponent of the unit. |
DecimalPrefix* Calculator::getExactDecimalPrefix | ( | int | exp10, |
int | exp = 1 |
||
) | const |
Returns a decimal prefix with exactly the provided value, that fulfils the condition prefix->exponent(exp) == exp10.
exp10 | Base-10 exponent of the requested prefix. |
exp | The exponent of the unit. |
Returns a prefix with exactly the provided value, that fulfils the condition prefix->value(exp) == o.
o | Value of the requested prefix. |
exp | The exponent of the unit. |
std::string Calculator::getExchangeRatesFileName | ( | int | index = 1 | ) |
Name of the exchange rates file on local disc. Multiple exchange rates sources might be used. Iterate over these, using the index parameter, until an empty string is returned.
index | The index (starting at one) of the exchange rate source |
time_t Calculator::getExchangeRatesTime | ( | int | index = -1 | ) |
Modification time of the exchange rates file.
std::string Calculator::getExchangeRatesUrl | ( | int | index = 1 | ) |
Url of the exchange rates file on the Internet. Multiple exchange rates sources might be used. Iterate over these, using the index parameter, until an empty string is returned.
index | The index (starting at one) of the exchange rate source |
MathFunction* Calculator::getFunction | ( | size_t | index | ) | const |
Returns function for an index (starting at zero). All functions can be traversed by starting at index zero and increasing the index until NULL is returned.
index | Index of function. |
Unit* Calculator::getGraUnit | ( | ) |
Returns the gradians unit.
MathStructure* Calculator::getId | ( | size_t | id | ) |
Returns a stored value. Mainly for internal use.
id | Storage id. |
BinaryPrefix* Calculator::getNearestBinaryPrefix | ( | int | exp2, |
int | exp = 1 |
||
) | const |
Returns the nearest binary prefix for a value.
exp10 | Base-2 exponent of the value. |
exp | The exponent of the unit. |
DecimalPrefix* Calculator::getNearestDecimalPrefix | ( | int | exp10, |
int | exp = 1 |
||
) | const |
Returns the nearest decimal prefix for a value.
exp10 | Base-10 exponent of the value. |
exp | The exponent of the unit. |
BinaryPrefix* Calculator::getOptimalBinaryPrefix | ( | const Number & | exp2, |
const Number & | exp | ||
) | const |
Returns the best suited binary prefix for a value.
exp10 | Base-2 exponent of the value. |
exp | The exponent of the unit. |
BinaryPrefix* Calculator::getOptimalBinaryPrefix | ( | int | exp2, |
int | exp = 1 |
||
) | const |
Returns the best suited binary prefix for a value.
exp10 | Base-2 exponent of the value. |
exp | The exponent of the unit. |
DecimalPrefix* Calculator::getOptimalDecimalPrefix | ( | const Number & | exp10, |
const Number & | exp, | ||
bool | all_prefixes = true |
||
) | const |
Returns the best suited decimal prefix for a value.
exp10 | Base-10 exponent of the value. |
exp | The exponent of the unit. |
all_prefixes | If false, prefixes which is not a multiple of thousand (centi, deci, deka, hekto) will be skipped. |
DecimalPrefix* Calculator::getOptimalDecimalPrefix | ( | int | exp10, |
int | exp = 1 , |
||
bool | all_prefixes = true |
||
) | const |
Returns the best suited decimal prefix for a value.
exp10 | Base-10 exponent of the value. |
exp | The exponent of the unit. |
all_prefixes | If false, prefixes which is not a multiple of thousand (centi, deci, deka, hekto) will be skipped. |
int Calculator::getPrecision | ( | ) | const |
Returns default precision for approximate calculations.
Prefix* Calculator::getPrefix | ( | size_t | index | ) | const |
Returns prefix for an index (starting at zero). All prefixes can be traversed by starting at index zero and increasing the index until NULL is returned.
index | Index of prefix. |
Prefix* Calculator::getPrefix | ( | std::string | name_ | ) | const |
Returns prefix with provided name.
name_ | Name of prefix to retrieve. |
Unit* Calculator::getRadUnit | ( | ) |
Returns the radians unit.
Unit* Calculator::getUnit | ( | size_t | index | ) | const |
Returns unit for an index (starting at zero). All units can be traversed by starting at index zero and increasing the index until NULL is returned.
index | Index of unit. |
Variable* Calculator::getVariable | ( | size_t | index | ) | const |
Returns variable for an index (starting at zero). All variables can be traversed by starting at index zero and increasing the index until NULL is returned.
index | Index of variable. |
bool Calculator::hasFunction | ( | MathFunction * | f | ) |
Checks if a function exists/is registered in the calculator.
bool Calculator::hasUnit | ( | Unit * | u | ) |
Checks if a unit exists/is registered in the calculator.
bool Calculator::hasVariable | ( | Variable * | v | ) |
Checks if a variable exists/is registered in the calculator.
int Calculator::loadDefinitions | ( | const char * | file_name, |
bool | is_user_defs = true , |
||
bool | check_duplicates_of_global = false |
||
) |
Load definitions from a file.
file_name | The path to the file to load. |
is_user_defs | true if the definitions are local, false if they are global. |
bool Calculator::loadExchangeRates | ( | ) |
Load exchange rates. Use before loadGlobalCurrencies() or loadGlobalDefinitions().
bool Calculator::loadGlobalCurrencies | ( | ) |
Load currencies.
bool Calculator::loadGlobalDataSets | ( | ) |
Load data sets.
bool Calculator::loadGlobalDefinitions | ( | ) |
Load all standard global (system wide) definitions from the global data directory ($PREFIX/share/qalculate).
bool Calculator::loadGlobalDefinitions | ( | std::string | filename | ) |
Load global (system wide) definitions from a file in the global data directory ($PREFIX/share/qalculate).
filename | Name of the file in the global data directory. |
bool Calculator::loadGlobalFunctions | ( | ) |
Load functions.
bool Calculator::loadGlobalPrefixes | ( | ) |
Load prefixes.
bool Calculator::loadGlobalUnits | ( | ) |
Load units.
bool Calculator::loadGlobalVariables | ( | ) |
Load variables.
bool Calculator::loadLocalDefinitions | ( | ) |
Load local, user specific, definitions from the local definitions directory (~/.qalculate/definitions). All files in the directory and in the datasets subdirectory are loaded.
std::string Calculator::localizeExpression | ( | std::string | str, |
const ParseOptions & | po = default_parse_options |
||
) | const |
Returns a localized expressions. Affects decimal signs and argument separators.
str | The expression to localize. |
std::string Calculator::localToString | ( | bool | include_spaces = true | ) | const |
Returns the translated text string used in expressions for converting to a specific unit expression (ex "5 meters to feet.
CalculatorMessage* Calculator::message | ( | ) |
Returns the first message in queue.
void Calculator::message | ( | MessageType | mtype, |
int | message_category, | ||
const char * | TEMPLATE, | ||
... | |||
) |
Put a message in the message queue.
bool Calculator::nameTaken | ( | std::string | name, |
ExpressionItem * | object = NULL |
||
) |
Checks if a name is used by another object which is not allowed to have the same name.
name | Name. |
object | Object to exclude from check. |
CalculatorMessage* Calculator::nextMessage | ( | ) |
Removes the first message in queue and returns the next.
MathStructure Calculator::parse | ( | std::string | str, |
const ParseOptions & | po = default_parse_options |
||
) |
Parse an expression and place in a MathStructure object.
str | Expression |
po | Parse options. |
size_t Calculator::parseAddId | ( | MathFunction * | f, |
const std::string & | str, | ||
const ParseOptions & | po, | ||
bool | persistent = false |
||
) |
Stores a function value with arguments parsed from a text string using Function::parse(), with an associated id. Mainly for internal use.
f | Mathematical function. |
str | Arguments. |
po | Parse options. |
persistent | If false the values will be removed from storage when retrieved with getId(). |
void Calculator::prefixNameChanged | ( | Prefix * | p, |
bool | new_item = false |
||
) |
Used internally.
std::string Calculator::print | ( | const MathStructure & | mstruct, |
int | milliseconds = 100000 , |
||
const PrintOptions & | po = default_print_options |
||
) |
Calls MathStructure::format(po) and MathStructure::print(po). The process is aborted after msecs milliseconds.
void Calculator::reset | ( | ) |
Unloads all non-builtin variables, functions and units.
void Calculator::resetFunctions | ( | ) |
Unloads all non-builtin functions.
void Calculator::resetUnits | ( | ) |
Unloads all non-builtin units.
void Calculator::resetVariables | ( | ) |
Unloads all non-builtin variables.
void Calculator::RPNStackEnter | ( | MathStructure * | mstruct, |
bool | eval = false , |
||
const EvaluationOptions & | eo = default_user_evaluation_options |
||
) |
Adds a value first on the RPN stack.
mstruct | Value. |
eval | If true, the the mathematical structure will be evaluated first. |
bool Calculator::RPNStackEnter | ( | MathStructure * | mstruct, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options |
||
) |
Evaluates a value and adds the result first on the RPN stack. This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
mstruct | Value. |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. |
eo | Options for the evaluation of the expression. |
void Calculator::RPNStackEnter | ( | std::string | str, |
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL , |
||
MathStructure * | to_struct = NULL , |
||
bool | make_to_division = true |
||
) |
Calculates an expression adds the result first on the RPN stack. The expression should be unlocalized first with unlocalizeExpression().
str | Expression. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the result of the parsing of the expression. |
[out] | to_struct | NULL or a math structure to fill with unit expression parsed after "to". |
make_to_division | If true, the expression after "to" will be interpreted as a unit epxression to convert the result to. |
bool Calculator::RPNStackEnter | ( | std::string | str, |
int | msecs, | ||
const EvaluationOptions & | eo = default_user_evaluation_options , |
||
MathStructure * | parsed_struct = NULL , |
||
MathStructure * | to_struct = NULL , |
||
bool | make_to_division = true |
||
) |
Calculates an expression and adds the result first on the RPN stack. The expression should be unlocalized first with unlocalizeExpression(). This function starts the calculation in a separate thread and will return when the calculation has started unless a maximum time has been specified. The calculation can then be stopped with abort().
str | Expression. | |
msecs | The maximum time for the calculation in milliseconds. If msecs <= 0 the time will be unlimited. | |
eo | Options for the evaluation and parsing of the expression. | |
[out] | parsed_struct | NULL or a math structure to fill with the result of the parsing of the expression. |
[out] | to_struct | NULL or a math structure to fill with unit expression parsed after "to". |
make_to_division | If true, the expression after "to" will be interpreted as a unit epxression to convert the result to. |
bool Calculator::saveDefinitions | ( | ) |
Save local definitions to ~/.qalculate/definitions/
bool Calculator::separateToExpression | ( | std::string & | str, |
std::string & | to_str, | ||
const EvaluationOptions & | eo, | ||
bool | keep_modifiers = false , |
||
bool | allow_empty_from = false |
||
) | const |
Split an expression string after and before " to ".
[out] | str | The expression. Will be set to the string before " to ". |
[out] | to_str | Will be set to the string after " to ". |
eo | Options for the evaluation and parsing of the expression (nothing will be done if units are not enabled). |
void Calculator::setDefaultAssumptions | ( | Assumptions * | ass | ) |
Set assumptions for objects without own assumptions (unknown variables and symbols).
void Calculator::setLocale | ( | ) |
Sets argument separator and decimal sign from the current locale. Mainly for internal use.
void Calculator::setPrecision | ( | int | precision = DEFAULT_PRECISION | ) |
Set default precision for approximate calculations.
precision | Precision. |
void Calculator::startControl | ( | int | milliseconds = 0 | ) |
Called before calculation, formatting or printing of a MathStructure (Calculator::calculate(), without maximum time, MathStructure::eval(), MathStructure::format() and MathStructure::print(), etc.) or printing of a Number (using Number::print) to be able to abort the process. Always use Calculator::stopControl() after finishing.
milliseconds | The maximum time for the process in milliseconds. If msecs <= 0 the time will be unlimited (stop with abort()). |
bool Calculator::stillHasFunction | ( | MathFunction * | f | ) |
Checks if a pointer points to a mathematical function that still exists in the calculator. As opposed to hasFunction(), this function only checks if the mathematical function has been deleted.
bool Calculator::stillHasUnit | ( | Unit * | u | ) |
Checks if a pointer points to a unit that still exists in the calculator. As opposed to hasUnit(), this function only checks if the unit has been deleted.
bool Calculator::stillHasVariable | ( | Variable * | v | ) |
Checks if a pointer points to a variable that still exists in the calculator. As opposed to hasFunction(), this function only checks if the mathematical function has been deleted.
void Calculator::stopControl | ( | void | ) |
Always call this function after Calculator::startControl() after formatting, printing or calculation has finished.
void Calculator::terminateThreads | ( | ) |
Terminate calculation and print threads if started. Do not use to terminate calculation.
std::string Calculator::unlocalizeExpression | ( | std::string | str, |
const ParseOptions & | po = default_parse_options |
||
) | const |
Returns an unlocalized expressions. Affects decimal signs and argument separators.
str | The expression to unlocalize. |
void Calculator::unsetLocale | ( | ) |
Resets argument separator and decimal sign. Mainly for internal use.
void Calculator::useDecimalPoint | ( | bool | comma_as_separator = false | ) |
Use point as decimal separator. To use comma as an ignored separator in numbers, must be invoked with comma_as_separator = true, to change the default function argument separator to semicolon, in addition to using ParseOptions::comma_as_separator.
void Calculator::useIntervalArithmetic | ( | bool | use_interval_arithmetic = true | ) |
Set if interval should be produced for approximate functions and irrational numbers. This does not affect calculation of lower precision explicit intervals (uncertainty propagation).
use_interval_arithmetic | Set true to activate, or false to deactivate, interval arithmetic. |
int Calculator::usesBinaryPrefixes | ( | ) | const |
Controls if binary, instead of decimal, prefixes will be used by default. 1 = use binary prefixes for information units, 2 = use binary prefixes for all units.
bool Calculator::usesIntervalArithmetic | ( | ) | const |
Returns true if interval arithmetic are activated.
bool Calculator::variableNameIsValid | ( | const char * | name_ | ) |
Tests if a name is valid for a variable.
name_ | Variable name. |
bool Calculator::variableNameIsValid | ( | const std::string & | name_ | ) |
Tests if a name is valid for a variable.
name_ | Variable name. |