Skip to content

Commit

Permalink
Fix and improve to Calculator::findMatchUnit() (fixes matching unit f…
Browse files Browse the repository at this point in the history
…or m/s); Add derived units for kJ, kcal, and kcal/g; Improve API documentation for number base; Fix "E" at end of longitude replaced with "e"; Fix segfault with curly brackets in expression; Apply automatic unit conversion after conversion to variables and expressions with non-unit objects; Unit conversion tweaks; Fix exact calculation of fibonacci(-n), for n > 3; Precalculate fibonacci() integer argument to avoid approximation; Improve api docs; Update man page; Update translations; Update exchange rates; Increment version number
  • Loading branch information
hanna-kn committed Aug 21, 2023
1 parent 3093573 commit 068d164
Show file tree
Hide file tree
Showing 38 changed files with 19,959 additions and 19,208 deletions.
52 changes: 52 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
2023-08-19 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Fix and improve to Calculator::findMatchUnit() (fixes matching unit for m/s)

2023-08-13 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Fix segfault with curly brackets in expression
* Apply automatic unit conversion after conversion to variable

2023-08-10 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Fix "E" at end of longitude replaced with "e"
* Add derived units for kJ, kcal, and kcal/g

2023-08-02 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Concise uncertainty input (disabled by default)

2023-07-30 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Round high precision intervals enclosing integers for integer arguments (excluding order argument of besselj() and bessely())

2023-07-28 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Add support for input of relative uncertainty using percentage (e.g. "5+/-2%") and output of interval using relative or concise (e.g. "1.2345(67)") notation

2023-07-27 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Set unicode property of object name automatically (does not affect usage in definitions file)
* Keep prefixes for variable value in save() function
* Fix numerical value of lower and upper options in help text for interval display setting

2023-07-26 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Fix fibonacci() for non-integers
* Fix erroneous simplication of exponentiation when power is multiplication and base is a rational number < 1 in some case (e.g. "fibonacci(fibonacci(2))")

2023-07-25 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Add support for specifying position of sign bit in floating point functions

2023-07-23 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Use international foot as base unit for rod, and add U.S. survey rod unit

2023-07-19 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Add units for Electric Dipole Moment (C*m and Debye)
* Add units for electrical elastance (F^-1, Daraf, and V/C)
* Add and N/C as alternative unit for electric field strength
* Optimize rest of unit expression when converting to partial (insufficient) expression (e.g. 18MA×100ns to J)

2023-07-03 Hanna Knutsson <hanna.knutsson@protonmail.com>

* Replace occurrences in variable values in replace() function, when original expression contains unknown symbol/variable, and for "where" replacement
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dnl ----------------------
dnl | initialize autotools |---------------------------------------------------
dnl ----------------------

AC_INIT([libqalculate],[4.7.0])
AC_INIT([libqalculate],[4.8.0])
AC_CONFIG_SRCDIR(libqalculate/Calculator.cc)
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS(config.h)
Expand Down Expand Up @@ -69,7 +69,7 @@ AC_DEFINE([HAVE_PTHREADS],1,
dnl libtool versioning for libqalculate

dnl increment if the interface has additions, changes, removals.
QALCULATE_CURRENT=41
QALCULATE_CURRENT=42

dnl increment any time the source changes; set to
dnl 0 if you increment CURRENT
Expand All @@ -78,7 +78,7 @@ QALCULATE_REVISION=0
dnl increment if any interfaces have been added; set to 0
dnl if any interfaces have been removed. removal has
dnl precedence over adding, so set to 0 if both happened.
QALCULATE_AGE=19
QALCULATE_AGE=20

AC_SUBST(QALCULATE_CURRENT)
AC_SUBST(QALCULATE_REVISION)
Expand Down
60 changes: 30 additions & 30 deletions data/eurofxref-daily.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@
<gesmes:name>European Central Bank</gesmes:name>
</gesmes:Sender>
<Cube>
<Cube time='2023-06-26'>
<Cube currency='USD' rate='1.0918'/>
<Cube currency='JPY' rate='156.41'/>
<Cube time='2023-08-15'>
<Cube currency='USD' rate='1.0926'/>
<Cube currency='JPY' rate='159.04'/>
<Cube currency='BGN' rate='1.9558'/>
<Cube currency='CZK' rate='23.649'/>
<Cube currency='DKK' rate='7.4458'/>
<Cube currency='GBP' rate='0.85878'/>
<Cube currency='HUF' rate='369.10'/>
<Cube currency='PLN' rate='4.4363'/>
<Cube currency='RON' rate='4.9561'/>
<Cube currency='SEK' rate='11.6825'/>
<Cube currency='CHF' rate='0.9737'/>
<Cube currency='ISK' rate='148.90'/>
<Cube currency='NOK' rate='11.7080'/>
<Cube currency='TRY' rate='28.2813'/>
<Cube currency='AUD' rate='1.6346'/>
<Cube currency='BRL' rate='5.2177'/>
<Cube currency='CAD' rate='1.4354'/>
<Cube currency='CNY' rate='7.8972'/>
<Cube currency='HKD' rate='8.5481'/>
<Cube currency='IDR' rate='16438.22'/>
<Cube currency='ILS' rate='3.9565'/>
<Cube currency='INR' rate='89.5565'/>
<Cube currency='KRW' rate='1425.57'/>
<Cube currency='MXN' rate='18.6863'/>
<Cube currency='MYR' rate='5.1025'/>
<Cube currency='NZD' rate='1.7690'/>
<Cube currency='PHP' rate='60.863'/>
<Cube currency='SGD' rate='1.4765'/>
<Cube currency='THB' rate='38.399'/>
<Cube currency='ZAR' rate='20.3145'/>
<Cube currency='CZK' rate='24.138'/>
<Cube currency='DKK' rate='7.4519'/>
<Cube currency='GBP' rate='0.85955'/>
<Cube currency='HUF' rate='388.48'/>
<Cube currency='PLN' rate='4.4888'/>
<Cube currency='RON' rate='4.9395'/>
<Cube currency='SEK' rate='11.8390'/>
<Cube currency='CHF' rate='0.9586'/>
<Cube currency='ISK' rate='144.30'/>
<Cube currency='NOK' rate='11.4705'/>
<Cube currency='TRY' rate='29.5648'/>
<Cube currency='AUD' rate='1.6888'/>
<Cube currency='BRL' rate='5.4295'/>
<Cube currency='CAD' rate='1.4742'/>
<Cube currency='CNY' rate='7.9605'/>
<Cube currency='HKD' rate='8.5482'/>
<Cube currency='IDR' rate='16760.11'/>
<Cube currency='ILS' rate='4.1156'/>
<Cube currency='INR' rate='91.0615'/>
<Cube currency='KRW' rate='1460.70'/>
<Cube currency='MXN' rate='18.7129'/>
<Cube currency='MYR' rate='5.0650'/>
<Cube currency='NZD' rate='1.8305'/>
<Cube currency='PHP' rate='62.124'/>
<Cube currency='SGD' rate='1.4829'/>
<Cube currency='THB' rate='38.667'/>
<Cube currency='ZAR' rate='20.9813'/>
</Cube>
</Cube>
</gesmes:Envelope>
5 changes: 3 additions & 2 deletions data/functions.xml.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<QALCULATE version="4.7.0">
<QALCULATE version="4.8.0">
<category>
<_title>Matrices &amp; Vectors</_title>
<builtin_function name="vector">
Expand Down Expand Up @@ -817,7 +817,8 @@
<_title>Fibonacci Number</_title>
<_names>r:fibonacci</_names>
<_description>Returns the n-th term of the Fibonacci sequence.</_description>
<expression>if(isInteger(\x),(golden^\x−(1−golden)^\x)/sqrt(5),(golden^\x-cos(\x*pi)*golden^(-\x))/sqrt(5))</expression>
<subfunction precalculate="true">\x</subfunction>
<expression>if(isInteger(\1),(golden^\1−(1−golden)^\1)/sqrt(5),(golden^\x-cos(\x*pi*rad)*golden^(-\x))/sqrt(5))</expression>
<argument type="number" index="1">
<_title>Index (n)</_title>
<test>false</test>
Expand Down
2 changes: 1 addition & 1 deletion data/rates.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"motd":{"msg":"If you or your company use this project or like what we doing, please consider backing us so we can continue maintaining and evolving this project.","url":"https://exchangerate.host/#/donate"},"success":true,"base":"EUR","date":"2023-06-27","rates":{"AED":4.010662,"AFN":93.730707,"ALL":107.198774,"AMD":422.5795,"ANG":1.968224,"AOA":870.44807,"ARS":277.812485,"AUD":1.625614,"AWG":1.969564,"AZN":1.857386,"BAM":1.959582,"BBD":2.184069,"BDT":118.163046,"BGN":1.955466,"BHD":0.412194,"BIF":3081.55144,"BMD":1.093027,"BND":1.478471,"BOB":7.545358,"BRL":5.208485,"BSD":1.09303,"BTC":0.000036,"BTN":89.569048,"BWP":14.636924,"BYN":2.756592,"BZD":2.200897,"CAD":1.433232,"CDF":2579.775739,"CHF":0.978343,"CLF":0.032925,"CLP":879.797248,"CNH":7.878872,"CNY":7.875799,"COP":4556.596255,"CRC":591.422093,"CUC":1.093038,"CUP":28.120019,"CVE":110.422153,"CZK":23.62194,"DJF":194.418862,"DKK":7.444007,"DOP":60.033866,"DZD":148.062992,"EGP":33.740887,"ERN":16.380553,"ETB":60.041339,"EUR":1,"FJD":2.422919,"FKP":0.857648,"GBP":0.857761,"GEL":2.877424,"GGP":0.858088,"GHS":12.503468,"GIP":0.857911,"GMD":65.127621,"GNF":9389.038085,"GTQ":8.561196,"GYD":230.947673,"HKD":8.550524,"HNL":26.884728,"HRK":7.531165,"HTG":151.239242,"HUF":368.950134,"IDR":16368.077674,"ILS":3.962327,"IMP":0.857756,"INR":89.500953,"IQD":1429.373706,"IRR":46136.72089,"ISK":148.817269,"JEP":0.858015,"JMD":168.373111,"JOD":0.774825,"JPY":156.678912,"KES":154.190318,"KGS":95.356471,"KHR":4498.233326,"KMF":493.390122,"KPW":982.794144,"KRW":1420.934349,"KWD":0.336212,"KYD":0.91084,"KZT":491.533597,"LAK":20794.834854,"LBP":16394.857643,"LKR":337.707015,"LRD":196.012792,"LSL":20.307136,"LYD":5.2311,"MAD":10.938942,"MDL":19.614032,"MGA":4962.807366,"MKD":61.604404,"MMK":2293.077561,"MNT":3842.72447,"MOP":8.806163,"MRU":37.738675,"MUR":49.575996,"MVR":16.707818,"MWK":1111.135717,"MXN":18.69093,"MYR":5.093091,"MZN":69.778211,"NAD":20.376514,"NGN":841.45516,"NIO":39.935421,"NOK":11.669907,"NPR":143.313206,"NZD":1.764266,"OMR":0.421651,"PAB":1.092565,"PEN":3.969733,"PGK":3.891442,"PHP":60.533061,"PKR":312.683525,"PLN":4.435349,"PYG":7928.934274,"QAR":3.984635,"RON":4.953226,"RSD":117.1917,"RUB":92.611851,"RWF":1296.692065,"SAR":4.095866,"SBD":9.093976,"SCR":14.574303,"SDG":656.833909,"SEK":11.676801,"SGD":1.475057,"SHP":0.858438,"SLL":19290.063828,"SOS":621.858875,"SRD":41.094506,"SSP":142.243433,"STD":24923.648152,"STN":24.534782,"SVC":9.554118,"SYP":2743.666261,"SZL":20.297908,"THB":38.406498,"TJS":11.924611,"TMT":3.833194,"TND":3.37976,"TOP":2.577529,"TRY":28.407851,"TTD":7.418316,"TWD":33.863752,"TZS":2620.784679,"UAH":40.332904,"UGX":4017.532473,"USD":1.092791,"UYU":41.006516,"UZS":12544.015004,"VES":30.11216,"VND":25700.009998,"VUV":129.924413,"WST":2.977118,"XAF":655.543979,"XAG":0.048667,"XAU":0.001833,"XCD":2.951499,"XDR":0.818669,"XOF":655.543898,"XPD":0.00186,"XPF":119.257687,"XPT":0.001299,"YER":273.326105,"ZAR":20.28573,"ZMW":18.613525,"ZWL":351.622696}}
{"motd":{"msg":"If you or your company use this project or like what we doing, please consider backing us so we can continue maintaining and evolving this project.","url":"https://exchangerate.host/#/donate"},"success":true,"base":"EUR","date":"2023-08-15","rates":{"AED":4.005282,"AFN":92.036551,"ALL":103.933155,"AMD":423.807844,"ANG":1.972029,"AOA":900.533792,"ARS":381.497536,"AUD":1.677698,"AWG":1.962883,"AZN":1.854645,"BAM":1.955759,"BBD":2.181112,"BDT":119.743199,"BGN":1.954466,"BHD":0.41108,"BIF":3108.538799,"BMD":1.090845,"BND":1.48158,"BOB":7.559701,"BRL":5.412369,"BSD":1.091197,"BTC":0.000037,"BTN":90.74811,"BWP":14.834637,"BYN":2.761719,"BZD":2.204987,"CAD":1.467007,"CDF":2714.14633,"CHF":0.957909,"CLF":0.034225,"CLP":937.656569,"CNH":7.963774,"CNY":7.88824,"COP":4335.33265,"CRC":585.434743,"CUC":1.090767,"CUP":28.074084,"CVE":110.21544,"CZK":24.044737,"DJF":194.78399,"DKK":7.448303,"DOP":62.222929,"DZD":148.15372,"EGP":33.683519,"ERN":16.354447,"ETB":60.341683,"EUR":1,"FJD":2.461777,"FKP":0.860122,"GBP":0.860196,"GEL":2.846087,"GGP":0.860289,"GHS":12.362839,"GIP":0.860187,"GMD":66.122794,"GNF":9403.519699,"GTQ":8.59753,"GYD":228.874114,"HKD":8.527899,"HNL":26.912617,"HRK":7.530402,"HTG":149.330321,"HUF":384.131775,"IDR":16731.711559,"ILS":4.088733,"IMP":0.859962,"INR":90.784753,"IQD":1432.813873,"IRR":46116.912461,"ISK":144.009199,"JEP":0.860107,"JMD":168.964095,"JOD":0.772056,"JPY":158.595308,"KES":156.776436,"KGS":96.235188,"KHR":4533.829347,"KMF":491.287785,"KPW":981.210942,"KRW":1457.261679,"KWD":0.336065,"KYD":0.911949,"KZT":492.387466,"LAK":21284.815909,"LBP":16420.88276,"LKR":352.25071,"LRD":203.056416,"LSL":20.777942,"LYD":5.246594,"MAD":10.861165,"MDL":19.226345,"MGA":4943.778361,"MKD":61.591694,"MMK":2297.308851,"MNT":3761.309162,"MOP":8.811358,"MRU":41.626536,"MUR":49.388583,"MVR":16.736304,"MWK":1187.271279,"MXN":18.598808,"MYR":5.048376,"MZN":69.63881,"NAD":21.620223,"NGN":841.510326,"NIO":40.021409,"NOK":11.411416,"NPR":145.1971,"NZD":1.822402,"OMR":0.419892,"PAB":1.091067,"PEN":4.034745,"PGK":3.976236,"PHP":61.928225,"PKR":311.510119,"PLN":4.445954,"PYG":7948.215301,"QAR":3.989348,"RON":4.938695,"RSD":117.215513,"RUB":105.109447,"RWF":1294.208187,"SAR":4.091199,"SBD":9.124487,"SCR":14.495604,"SDG":655.231605,"SEK":11.756795,"SGD":1.478629,"SHP":0.860058,"SLL":22861.669469,"SOS":623.017689,"SRD":41.708635,"SSP":142.014651,"STD":24292.383814,"STN":24.4896,"SVC":9.572723,"SYP":2739.246465,"SZL":20.771805,"THB":38.503109,"TJS":12.006754,"TMT":3.827045,"TND":3.368043,"TOP":2.595964,"TRY":29.495496,"TTD":7.420911,"TWD":34.802008,"TZS":2740.470037,"UAH":40.405837,"UGX":4064.127635,"USD":1.090443,"UYU":41.327233,"UZS":13195.871117,"VES":32.76418,"VND":26026.125913,"VUV":129.435209,"WST":2.964437,"XAF":655.547265,"XAG":0.04853,"XAU":0.001711,"XCD":2.946371,"XDR":0.819012,"XOF":655.546871,"XPD":0.001215,"XPF":119.258016,"XPT":0.001171,"YER":272.940639,"ZAR":20.786844,"ZMW":21.112961,"ZWL":351.055859}}
34 changes: 33 additions & 1 deletion data/units.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@
<unit type="composite">
<system>CGS</system>
<title>Statcoulomb Centimeter</title>
<hidden>true</hidden>
<hidden>true</hidden>
<names>r:statcoulomb_cm</names>
<part>
<unit>statcoulomb</unit>
Expand Down Expand Up @@ -3593,6 +3593,15 @@
<exponent>1</exponent>
</base>
</unit>
<unit type="composite">
<_title>Kilojoule</_title>
<names>r:kJ_c</names>
<part>
<unit>J</unit>
<prefix>3</prefix>
<exponent>1</exponent>
</part>
</unit>
<unit type="composite">
<_title>Watt Hour</_title>
<names>r:W_h</names>
Expand Down Expand Up @@ -3630,6 +3639,15 @@
<exponent>1</exponent>
</base>
</unit>
<unit type="composite">
<_title>Kilocalorie</_title>
<names>r:kcal_c</names>
<part>
<unit>cal</unit>
<prefix>3</prefix>
<exponent>1</exponent>
</part>
</unit>
<unit type="alias">
<_title>Calorie (capital C)</_title>
<_names>cr:Calorie,cp:Calories</_names>
Expand Down Expand Up @@ -3788,6 +3806,20 @@
<exponent>-1</exponent>
</part>
</unit>
<unit type="composite">
<_title>Kilocalerie per Gram</_title>
<names>r:kcal_p_g</names>
<part>
<unit>cal</unit>
<prefix>3</prefix>
<exponent>1</exponent>
</part>
<part>
<unit>g</unit>
<prefix>0</prefix>
<exponent>-1</exponent>
</part>
</unit>
</category>
<category>
<_title>Power</_title>
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = libqalculate-4.7.0
PROJECT_NAME = libqalculate-4.8.0

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down
4 changes: 2 additions & 2 deletions libqalculate/BuiltinFunctions-special.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ int BesseljFunction::calculate(MathStructure &mstruct, const MathStructure &varg
if(arg) {
arg->setTests(true);
bool b = true;
if(!mstruct.isNumber()) {
if(!mstruct.isInteger()) {
MathStructure m; m.setUndefined();
b = getArgumentDefinition(1)->test(m, 1, this, eo);
} else {
Expand Down Expand Up @@ -306,7 +306,7 @@ int BesselyFunction::calculate(MathStructure &mstruct, const MathStructure &varg
if(arg) {
arg->setTests(true);
bool b = true;
if(!mstruct.isNumber()) {
if(!mstruct.isInteger()) {
MathStructure m; m.setUndefined();
b = getArgumentDefinition(1)->test(m, 1, this, eo);
} else {
Expand Down
Loading

0 comments on commit 068d164

Please sign in to comment.