libqalculate-0.9.8
Classes | Macros | Enumerations | Variables
includes.h File Reference
#include <vector>
#include <string>
#include <stack>
#include <list>
#include <errno.h>
#include <stddef.h>
#include <math.h>
#include <float.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>

Classes

struct  SortOptions
 Options for ordering the parts of a mathematical expression/result before display. More...
 
struct  PrintOptions
 Options for formatting and display of mathematical structures/results. More...
 
struct  InternalPrintStruct
 
struct  ParseOptions
 Options for parsing expressions. More...
 
struct  EvaluationOptions
 Options for calculation. More...
 

Macros

#define unordered_map   Sgi::hash_map
 
#define COMPARISON_MIGHT_BE_LESS_OR_GREATER(i)   (i == COMPARISON_RESULT_UNKNOWN || i == COMPARISON_RESULT_NOT_EQUAL)
 
#define COMPARISON_NOT_FULLY_KNOWN(i)   (i == COMPARISON_RESULT_UNKNOWN || i == COMPARISON_RESULT_NOT_EQUAL || i == COMPARISON_RESULT_EQUAL_OR_LESS || i == COMPARISON_RESULT_EQUAL_OR_GREATER)
 
#define COMPARISON_IS_EQUAL_OR_GREATER(i)   (i == COMPARISON_RESULT_EQUAL || i == COMPARISON_RESULT_GREATER || i == COMPARISON_RESULT_EQUAL_OR_GREATER)
 
#define COMPARISON_IS_EQUAL_OR_LESS(i)   (i == COMPARISON_RESULT_EQUAL || i == COMPARISON_RESULT_LESS || i == COMPARISON_RESULT_EQUAL_OR_LESS)
 
#define COMPARISON_IS_NOT_EQUAL(i)   (i == COMPARISON_RESULT_NOT_EQUAL || i == COMPARISON_RESULT_LESS || i == COMPARISON_RESULT_GREATER)
 
#define COMPARISON_MIGHT_BE_EQUAL(i)   (i == COMPARISON_RESULT_UNKNOWN || i == COMPARISON_RESULT_EQUAL_OR_LESS || i == COMPARISON_RESULT_EQUAL_OR_GREATER)
 
#define COMPARISON_MIGHT_BE_NOT_EQUAL(i)   (i == COMPARISON_RESULT_UNKNOWN || i == COMPARISON_RESULT_EQUAL_OR_LESS || i == COMPARISON_RESULT_EQUAL_OR_GREATER)
 
#define NR_OF_PRIMES   174
 
#define SQP_LT_1000   11
 
#define SQP_LT_2000   17
 
#define SQP_LT_10000   28
 
#define SQP_LT_25000   40
 
#define SQP_LT_100000   68
 
#define BASE_ROMAN_NUMERALS   -1
 
#define BASE_TIME   -2
 
#define BASE_BINARY   2
 
#define BASE_OCTAL   8
 
#define BASE_DECIMAL   10
 
#define BASE_HEXADECIMAL   16
 
#define BASE_SEXAGESIMAL   60
 
#define EXP_BASE_3   -3
 
#define EXP_PRECISION   -1
 
#define EXP_NONE   0
 
#define EXP_PURE   1
 
#define EXP_SCIENTIFIC   3
 
#define CALCULATOR   calculator
 
#define DEFAULT_PRECISION   8
 
#define PRECISION   CALCULATOR->getPrecision()
 
#define SIGN_DEGREE   "°"
 
#define SIGN_POWER_0   "°"
 
#define SIGN_POWER_1   "¹"
 
#define SIGN_POWER_2   "²"
 
#define SIGN_POWER_3   "³"
 
#define SIGN_POWER_4   "³"
 
#define SIGN_POWER_5   "⁴"
 
#define SIGN_POWER_6   "⁶"
 
#define SIGN_POWER_7   "⁷"
 
#define SIGN_POWER_8   "⁸"
 
#define SIGN_POWER_9   "⁹"
 
#define SIGN_EURO   "€"
 
#define SIGN_POUND   "£"
 
#define SIGN_CENT   "¢"
 
#define SIGN_YEN   "¥"
 
#define SIGN_MICRO   "µ"
 
#define SIGN_PI   "π"
 
#define SIGN_MULTIPLICATION   "×"
 
#define SIGN_MULTIDOT   "⋅"
 
#define SIGN_MULTIBULLET   "∙"
 
#define SIGN_SMALLCIRCLE   "•"
 
#define SIGN_DIVISION_SLASH   "∕"
 
#define SIGN_DIVISION   "÷"
 
#define SIGN_MINUS   "−"
 
#define SIGN_PLUS   "+"
 
#define SIGN_SQRT   "√"
 
#define SIGN_ALMOST_EQUAL   "≈"
 
#define SIGN_APPROXIMATELY_EQUAL   "≅"
 
#define SIGN_ZETA   "ζ"
 
#define SIGN_GAMMA   "γ"
 
#define SIGN_PHI   "φ"
 
#define SIGN_LESS_OR_EQUAL   "≤"
 
#define SIGN_GREATER_OR_EQUAL   "≥"
 
#define SIGN_NOT_EQUAL   "≠"
 
#define SIGN_CAPITAL_SIGMA   "Σ"
 
#define SIGN_CAPITAL_PI   "Π"
 
#define SIGN_CAPITAL_OMEGA   "Ω"
 
#define SIGN_CAPITAL_GAMMA   "Γ"
 
#define SIGN_CAPITAL_BETA   "Β"
 
#define SIGN_INFINITY   "∞"
 
#define SIGN_PLUSMINUS   "±"
 
#define ID_WRAP_LEFT_CH   '{'
 
#define ID_WRAP_RIGHT_CH   '}'
 
#define DOT_CH   '.'
 
#define ZERO_CH   '0'
 
#define ONE_CH   '1'
 
#define TWO_CH   '2'
 
#define THREE_CH   '3'
 
#define FOUR_CH   '4'
 
#define FIVE_CH   '5'
 
#define SIX_CH   '6'
 
#define SEVEN_CH   '7'
 
#define EIGHT_CH   '8'
 
#define NINE_CH   '9'
 
#define PLUS_CH   '+'
 
#define MINUS_CH   '-'
 
#define MULTIPLICATION_CH   '*'
 
#define MULTIPLICATION_2_CH   ' '
 
#define DIVISION_CH   '/'
 
#define EXP_CH   'E'
 
#define EXP2_CH   'e'
 
#define POWER_CH   '^'
 
#define SPACE_CH   ' '
 
#define LEFT_PARENTHESIS_CH   '('
 
#define RIGHT_PARENTHESIS_CH   ')'
 
#define LEFT_VECTOR_WRAP_CH   '['
 
#define RIGHT_VECTOR_WRAP_CH   ']'
 
#define FUNCTION_VAR_PRE_CH   '\\'
 
#define COMMA_CH   ','
 
#define NAME_NUMBER_PRE_CH   '_'
 
#define UNIT_DIVISION_CH   '/'
 
#define AND_CH   '&'
 
#define OR_CH   '|'
 
#define LESS_CH   '<'
 
#define GREATER_CH   '>'
 
#define BITWISE_NOT_CH   '~'
 
#define LOGICAL_NOT_CH   '!'
 
#define NOT_CH   '!'
 
#define EQUALS_CH   '='
 
#define ID_WRAP_LEFT   "{"
 
#define ID_WRAP_RIGHT   "}"
 
#define ID_WRAPS   "{}"
 
#define DOT   "."
 
#define SEXADOT   ":"
 
#define COMMA   ","
 
#define COMMAS   ",;"
 
#define NUMBERS   "0123456789"
 
#define NUMBER_ELEMENTS   "0123456789.:"
 
#define SIGNS   "+-*/^"
 
#define OPERATORS   "~+-*/^&|!<>="
 
#define PARENTHESISS   "()"
 
#define LEFT_PARENTHESIS   "("
 
#define RIGHT_PARENTHESIS   ")"
 
#define VECTOR_WRAPS   "[]"
 
#define LEFT_VECTOR_WRAP   "["
 
#define RIGHT_VECTOR_WRAP   "]"
 
#define SPACES   " \t\n"
 
#define SPACE   " "
 
#define RESERVED   "\'@\\{}?\""
 
#define PLUS   "+"
 
#define MINUS   "-"
 
#define MULTIPLICATION   "*"
 
#define MULTIPLICATION_2   " "
 
#define DIVISION   "/"
 
#define EXP   "E"
 
#define EXPS   "Ee"
 
#define POWER   "^"
 
#define LOGICAL_AND   "&&"
 
#define LOGICAL_OR   "||"
 
#define LOGICAL_NOT   "!"
 
#define BITWISE_AND   "&"
 
#define BITWISE_OR   "|"
 
#define BITWISE_NOT   "~"
 
#define SHIFT_RIGHT   ">>"
 
#define SHIFT_LEFT   "<<"
 
#define LESS   "<"
 
#define GREATER   ">"
 
#define NOT   "!"
 
#define EQUALS   "="
 
#define SINF   "INF"
 
#define SNAN   "NAN"
 
#define UNDERSCORE   "_"
 
#define NOT_IN_NAMES   RESERVED OPERATORS SPACES SEXADOT DOT VECTOR_WRAPS PARENTHESISS COMMAS
 

Enumerations

enum  ExpressionItemType { TYPE_VARIABLE, TYPE_FUNCTION, TYPE_UNIT }
 Type of ExpressionItem. More...
 
enum  ComparisonResult {
  COMPARISON_RESULT_EQUAL, COMPARISON_RESULT_GREATER, COMPARISON_RESULT_LESS, COMPARISON_RESULT_EQUAL_OR_GREATER,
  COMPARISON_RESULT_EQUAL_OR_LESS, COMPARISON_RESULT_NOT_EQUAL, COMPARISON_RESULT_UNKNOWN
}
 The result of a comparison of two values.
 
enum  PlotLegendPlacement {
  PLOT_LEGEND_NONE, PLOT_LEGEND_TOP_LEFT, PLOT_LEGEND_TOP_RIGHT, PLOT_LEGEND_BOTTOM_LEFT,
  PLOT_LEGEND_BOTTOM_RIGHT, PLOT_LEGEND_BELOW, PLOT_LEGEND_OUTSIDE
}
 Placement of legend.
 
enum  PlotStyle {
  PLOT_STYLE_LINES, PLOT_STYLE_POINTS, PLOT_STYLE_POINTS_LINES, PLOT_STYLE_BOXES,
  PLOT_STYLE_HISTOGRAM, PLOT_STYLE_STEPS, PLOT_STYLE_CANDLESTICKS, PLOT_STYLE_DOTS
}
 Plot type/style.
 
enum  PlotSmoothing {
  PLOT_SMOOTHING_NONE, PLOT_SMOOTHING_UNIQUE, PLOT_SMOOTHING_CSPLINES, PLOT_SMOOTHING_BEZIER,
  PLOT_SMOOTHING_SBEZIER
}
 Smoothing a plotted lines.
 
enum  PlotFileType {
  PLOT_FILETYPE_AUTO, PLOT_FILETYPE_PNG, PLOT_FILETYPE_PS, PLOT_FILETYPE_EPS,
  PLOT_FILETYPE_LATEX, PLOT_FILETYPE_SVG, PLOT_FILETYPE_FIG
}
 File type for saving plot to image.
 
enum  MathOperation {
  OPERATION_MULTIPLY, OPERATION_DIVIDE, OPERATION_ADD, OPERATION_SUBTRACT,
  OPERATION_RAISE, OPERATION_EXP10, OPERATION_LOGICAL_AND, OPERATION_LOGICAL_OR,
  OPERATION_LOGICAL_XOR, OPERATION_BITWISE_AND, OPERATION_BITWISE_OR, OPERATION_BITWISE_XOR,
  OPERATION_LESS, OPERATION_GREATER, OPERATION_EQUALS_LESS, OPERATION_EQUALS_GREATER,
  OPERATION_EQUALS, OPERATION_NOT_EQUALS
}
 Mathematical operations.
 
enum  ComparisonType {
  COMPARISON_LESS, COMPARISON_GREATER, COMPARISON_EQUALS_LESS, COMPARISON_EQUALS_GREATER,
  COMPARISON_EQUALS, COMPARISON_NOT_EQUALS
}
 Comparison signs for comparison structures.
 
enum  SortFlags { SORT_DEFAULT = 1 << 0, SORT_SCIENTIFIC = 1 << 1 }
 
enum  NumberFractionFormat { FRACTION_DECIMAL, FRACTION_DECIMAL_EXACT, FRACTION_FRACTIONAL, FRACTION_COMBINED }
 
enum  MultiplicationSign { MULTIPLICATION_SIGN_ASTERISK, MULTIPLICATION_SIGN_DOT, MULTIPLICATION_SIGN_X }
 
enum  DivisionSign { DIVISION_SIGN_SLASH, DIVISION_SIGN_DIVISION_SLASH, DIVISION_SIGN_DIVISION }
 
enum  BaseDisplay { BASE_DISPLAY_NONE, BASE_DISPLAY_NORMAL, BASE_DISPLAY_ALTERNATIVE }
 
enum  ApproximationMode { APPROXIMATION_EXACT, APPROXIMATION_TRY_EXACT, APPROXIMATION_APPROXIMATE }
 
enum  StructuringMode { STRUCTURING_NONE, STRUCTURING_SIMPLIFY, STRUCTURING_FACTORIZE }
 
enum  AutoPostConversion { POST_CONVERSION_NONE, POST_CONVERSION_BEST, POST_CONVERSION_BASE }
 
enum  ReadPrecisionMode { DONT_READ_PRECISION, ALWAYS_READ_PRECISION, READ_PRECISION_WHEN_DECIMALS }
 
enum  AngleUnit { ANGLE_UNIT_NONE, ANGLE_UNIT_RADIANS, ANGLE_UNIT_DEGREES, ANGLE_UNIT_GRADIANS }
 
enum  ParsingMode { PARSING_MODE_ADAPTIVE, PARSING_MODE_IMPLICIT_MULTIPLICATION_FIRST, PARSING_MODE_CONVENTIONAL }
 

Variables

static string empty_string
 
static const int PRIMES []
 
static const int SQUARE_PRIMES []
 
static const struct SortOptions default_sort_options
 
static const struct PrintOptions default_print_options
 
static const struct InternalPrintStruct top_ips
 
static const struct ParseOptions default_parse_options
 
static const struct EvaluationOptions default_evaluation_options
 
MathStructure m_undefined
 
MathStructure m_empty_vector
 
MathStructure m_empty_matrix
 
MathStructure m_zero
 
MathStructure m_one
 
MathStructure m_minus_one
 
Number nr_zero
 
Number nr_one
 
Number nr_minus_one
 
EvaluationOptions no_evaluation
 
ExpressionName empty_expression_name
 
Calculatorcalculator
 

Enumeration Type Documentation

Enumerator
APPROXIMATION_EXACT 

Allow only exact results.

APPROXIMATION_TRY_EXACT 

Try to make the result as exact as possible.

APPROXIMATION_APPROXIMATE 

Calculate the result approximately directly.

Enumerator
POST_CONVERSION_NONE 

Do not do any conversion of units in addition to syncing.

POST_CONVERSION_BEST 

Convert to the best suited SI units (the least amount of units)

POST_CONVERSION_BASE 

Convert to base units.

Type of ExpressionItem.

Enumerator
TYPE_VARIABLE 

class Variable

TYPE_FUNCTION 

class MathFunction

TYPE_UNIT 

class Unit

Enumerator
FRACTION_DECIMAL 

Display numbers in decimal, not fractional, format (ex. 0.333333)

FRACTION_DECIMAL_EXACT 

Display as fraction if necessary to get an exact display of the result (ex. 1/3, but 0.25)

FRACTION_FRACTIONAL 

Display as fraction (ex. 4/3)

FRACTION_COMBINED 

Display as an integer and a fraction (ex. 3 + 1/2)

Enumerator
PARSING_MODE_ADAPTIVE 

The default adaptive mode works as the "parse implicit multiplication first" mode, unless spaces are found (<quote>1/5x = 1/(5*x)</quote>, but <quote>1/5 x = (1/5)*x</quote>). In the adaptive mode unit expressions are parsed separately (<quote>5 m/5 m/s = (5*m)/(5*(m/s)) = 1 s</quote>).

PARSING_MODE_IMPLICIT_MULTIPLICATION_FIRST 

In the "parse implicit multiplication first" mode, implicit multiplication is parsed before explicit multiplication (<quote>12/2(1+2) = 12/(2*3) = 2</quote>, <quote>5x/5y = (5*x)/(5*y) = x/y</quote>).

PARSING_MODE_CONVENTIONAL 

In the conventional mode implicit multiplication does not differ from explicit multiplication (<quote>12/2(1+2) = 12/2*3 = 18</quote>, <quote>5x/5y = 5*x/5*y = xy</quote>).

Enumerator
STRUCTURING_NONE 

Do not do any factorization or additional simplifications.

STRUCTURING_SIMPLIFY 

Simplify the result as much as possible.

STRUCTURING_FACTORIZE 

Factorize the result.

Variable Documentation

const int PRIMES[]
static
Initial value:
= {
2, 3, 5, 7, 11, 13, 17, 19, 21, 23, 29, 31, 37, 41, 31, 37,
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,
107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233,
239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307,
311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379,
383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449,
457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523,
541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607,
613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677,
683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761,
769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853,
857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937,
941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013
}
const int SQUARE_PRIMES[]
static
Initial value:
= {
4, 9, 25, 49, 121, 169, 289, 361, 441, 529,
841, 961, 1369, 1681, 961, 1369, 1681, 1849, 2209, 2809,
3481, 3721, 4489, 5041, 5329, 6241, 6889, 7921, 9409, 10201,
10609, 11449, 11881, 12769, 16129, 17161, 18769, 19321, 22201, 22801,
24649, 26569, 27889, 29929, 32041, 32761, 36481, 37249, 38809, 39601,
44521, 49729, 51529, 52441, 54289, 57121, 58081, 63001, 66049, 69169,
72361, 73441, 76729, 78961, 80089, 85849, 94249, 96721, 97969, 100489,
109561, 113569, 120409, 121801, 124609, 128881, 134689, 139129, 143641, 146689,
151321, 157609, 160801, 167281, 175561, 177241, 185761, 187489, 192721, 196249,
201601, 208849, 212521, 214369, 218089, 229441, 237169, 241081, 249001, 253009,
259081, 271441, 273529, 292681, 299209, 310249, 316969, 323761, 326041, 332929,
344569, 351649, 358801, 361201, 368449, 375769, 380689, 383161, 398161, 410881,
413449, 418609, 426409, 434281, 436921, 452929, 458329, 466489, 477481, 491401,
502681, 516961, 528529, 537289, 546121, 552049, 564001, 573049, 579121, 591361,
597529, 619369, 635209, 654481, 657721, 674041, 677329, 683929, 687241, 703921,
727609, 734449, 737881, 744769, 769129, 776161, 779689, 786769, 822649, 829921,
844561, 863041, 877969, 885481, 896809, 908209, 935089, 942841, 954529, 966289,
982081, 994009, 1018081, 1026169
}