mirror of
https://gitlab.com/rnger/amath
synced 2025-12-08 14:58:29 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1eaf09fa56 | ||
|
|
59d69ac760 | ||
|
|
5b6b5cc745 | ||
|
|
d34de7e7b5 | ||
|
|
f06a9a3421 | ||
|
|
140e74f3ce | ||
|
|
f067ba8f80 | ||
|
|
683a382359 | ||
|
|
13141f8fd6 | ||
|
|
484133b293 | ||
|
|
2f5a7f1a8e | ||
|
|
d723292cc7 | ||
|
|
f480dc1a19 | ||
|
|
78f598d49b | ||
|
|
6cf752a257 | ||
|
|
3374eebd4d | ||
|
|
44ea2ea898 | ||
|
|
5d69976c05 | ||
|
|
331a9141be |
@@ -14,3 +14,4 @@ catalog/flexcat/flexcat
|
||||
*_.3
|
||||
doxygen.warn
|
||||
*.deb
|
||||
Makefile
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
-------------------------------------------------------------------------------
|
||||
--- amath change history ---
|
||||
-------------------------------------------------------------------------------
|
||||
amath release history
|
||||
|
||||
v1.8.2 July 14 2017
|
||||
- MIPS support.
|
||||
- Improved endianness detection.
|
||||
- Fixed configuration errors.
|
||||
|
||||
v1.8.1 April 22 2017
|
||||
- OpenBSD support.
|
||||
- Fixed Haiku bug.
|
||||
|
||||
v1.8.0 April 13 2017
|
||||
- Fixed bugs in numeral systems.
|
||||
- Fixed bugs related to infinity (Inf).
|
||||
- Fixed bugs related to Not a Number (NaN).
|
||||
- Updated and cleanup documentation.
|
||||
- Cleaned up code structure.
|
||||
- OpenLibm support.
|
||||
|
||||
v1.7.1 March 26 2017
|
||||
- Haiku support.
|
||||
- Unified ANSI console.
|
||||
- Code cleanup.
|
||||
|
||||
v1.7.0 March 12 2017
|
||||
- Introduce scientific notation.
|
||||
- Introduce Not a Number (NaN).
|
||||
- Introduced scientific notation.
|
||||
- Introduced Not a Number (NaN).
|
||||
- Fixed bugs related to infinity (Inf).
|
||||
- Fixed bugs in log of complex numbers.
|
||||
- Fixed bugs in numeral systems.
|
||||
@@ -29,7 +49,7 @@ v1.6.3 February 03 2017
|
||||
|
||||
v1.6.2 January 24 2017
|
||||
- Fixed bug in memory allocation.
|
||||
- Fixed bug in native keybord input.
|
||||
- Fixed bug in native keyboard input.
|
||||
- Included build options in executables.
|
||||
- ARM support.
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
CFLAGS = -O2 -DWITHTEST -Wall -Isrc -Isrc/main
|
||||
CXXFLAGS = -O2 -DWITHTEST -Wall -Isrc -Isrc/main
|
||||
AR = ar
|
||||
RANLIB = ranlib
|
||||
LFLAGS = -lappsystem -lfunctions -lstatement -lappmain -lfunctions -lstatement -lappmain -lamathapp -lamathcplex -lamath -lamathc -lstdc++
|
||||
LPATH = -Lsrc/lib -Lsrc/clib -Lsrc/real -Lsrc/cplex -Lsrc/main/function -Lsrc/main/statement -Lsrc/main -Lsrc/system
|
||||
LPATHS = -Lsrc/lib/static -Lsrc/clib/static -Lsrc/real/static -Lsrc/cplex/static -Lsrc/main/function -Lsrc/main/statement -Lsrc/main -Lsrc/system
|
||||
FLXCAT = build/flexcat/flexcat
|
||||
MKDIR = mkdir -p
|
||||
DEL = rm -f
|
||||
INSTALLP = install -m 0755
|
||||
INSTALLM = install -m 0644
|
||||
PREFIX = /usr
|
||||
INSTDIRP = ${DESTDIR}${PREFIX}/bin
|
||||
INSTDIRM = ${DESTDIR}${PREFIX}/share/man/man1
|
||||
|
||||
all: shared-app
|
||||
app: appmain functions statement appsystem
|
||||
libs: amathapp amath amathc amathcplex
|
||||
|
||||
amath: static-app
|
||||
static: static-app
|
||||
|
||||
src/main.o: src/main.cpp
|
||||
${CXX} ${CXXFLAGS} -c src/main.cpp -o src/main.o
|
||||
|
||||
appmain:
|
||||
cd src/main && ${MAKE}
|
||||
|
||||
appsystem:
|
||||
cd src/system && ${MAKE}
|
||||
|
||||
functions:
|
||||
cd src/main/function && ${MAKE}
|
||||
|
||||
statement:
|
||||
cd src/main/statement && ${MAKE}
|
||||
|
||||
amathapp:
|
||||
cd src/lib && ${MAKE}
|
||||
|
||||
amath:
|
||||
cd src/real && ${MAKE}
|
||||
|
||||
amathc:
|
||||
cd src/clib && ${MAKE}
|
||||
|
||||
amathcplex:
|
||||
cd src/cplex && ${MAKE}
|
||||
|
||||
localize:
|
||||
cd build/flexcat && ${MAKE}
|
||||
${FLXCAT} text/keyword.cd src/localize/kword.h=text/keyword.sd
|
||||
${FLXCAT} text/help.cd src/localize/help.h=text/help.sd
|
||||
${FLXCAT} text/ident.cd src/localize/ident.h=text/ident.sd
|
||||
${FLXCAT} text/text.cd src/localize/text.h=text/text.sd
|
||||
|
||||
catalogs:
|
||||
cd build/flexcat && ${MAKE}
|
||||
${MKDIR} dist/catalog/english
|
||||
${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG dist/catalog/english/amath-help.catalog
|
||||
${FLXCAT} text/ident.cd catalog/english/amath-ident.ct CATALOG dist/catalog/english/amath-ident.catalog
|
||||
${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG dist/catalog/english/amath-text.catalog
|
||||
${MKDIR} dist/catalog/dansk
|
||||
${FLXCAT} text/help.cd catalog/dansk/amath-help.ct CATALOG dist/catalog/dansk/amath-help.catalog
|
||||
${FLXCAT} text/ident.cd catalog/dansk/amath-ident.ct CATALOG dist/catalog/dansk/amath-ident.catalog
|
||||
${FLXCAT} text/text.cd catalog/dansk/amath-text.ct CATALOG dist/catalog/dansk/amath-text.catalog
|
||||
${FLXCAT} text/keyword.cd catalog/dansk/amath-keyword.ct CATALOG dist/catalog/dansk/amath-keyword.catalog
|
||||
|
||||
shared-app: app libs src/main.o
|
||||
${CC} ${CFLAGS} -s src/main.o -o amath ${LPATH} ${LFLAGS}
|
||||
|
||||
static-app: src/main.o
|
||||
cd src/lib && ${MAKE} static
|
||||
cd src/clib && ${MAKE} static
|
||||
cd src/real && ${MAKE} static
|
||||
cd src/cplex && ${MAKE} static
|
||||
cd src/main && ${MAKE} static
|
||||
cd src/system && ${MAKE} static
|
||||
cd src/main/function && ${MAKE} static
|
||||
cd src/main/statement && ${MAKE} static
|
||||
${CC} ${CFLAGS} -s src/main.o -o amath ${LPATHS} ${LFLAGS}
|
||||
|
||||
.PHONY: test
|
||||
test: amath
|
||||
LD_LIBRARY_PATH=src/clib/:src/lib:src/cplex:scr/real
|
||||
./amath test
|
||||
|
||||
.PHONY: install
|
||||
install: shared-app
|
||||
cd src/lib && ${MAKE} install
|
||||
cd src/clib && ${MAKE} install
|
||||
cd src/real && ${MAKE} install
|
||||
cd src/cplex && ${MAKE} install
|
||||
${INSTALLP} amath ${INSTDIRP}/amath
|
||||
${INSTALLM} amath.1 ${INSTDIRM}/amath.1
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
cd src/lib && ${MAKE} uninstall
|
||||
cd src/clib && ${MAKE} uninstall
|
||||
cd src/real && ${MAKE} uninstall
|
||||
cd src/cplex && ${MAKE} uninstall
|
||||
${DEL} ${INSTDIRP}/amath
|
||||
${DEL} ${INSTDIRM}/amath.1
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
cd src/lib && ${MAKE} clean
|
||||
cd src/clib && ${MAKE} clean
|
||||
cd src/real && ${MAKE} clean
|
||||
cd src/cplex && ${MAKE} clean
|
||||
cd src/main && ${MAKE} clean
|
||||
cd src/system && ${MAKE} clean
|
||||
cd src/main/function && ${MAKE} clean
|
||||
cd src/main/statement && ${MAKE} clean
|
||||
cd build/flexcat && ${MAKE} clean
|
||||
${DEL} src/main.o amath
|
||||
|
||||
@@ -29,7 +29,4 @@ Install by copying the desired amath binary to C: or any other appropriate locat
|
||||
> amath version
|
||||
|
||||
Run regression tests:
|
||||
> amath-test test
|
||||
|
||||
Load amath into memory:
|
||||
> resident amath pure
|
||||
> amath test
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
.TH "amath" 1 "Wed Mar 1 2017" "Version 1.7.0" "amath" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.\" Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.TH amath 1 "Version 1.8.2" "July 14 2017"
|
||||
.SH NAME
|
||||
amath \- Statements and functions
|
||||
|
||||
amath \- Simple command line calculator
|
||||
.SH SYNOPSIS
|
||||
\fCamath [expression]\fP
|
||||
|
||||
.SH Description
|
||||
\fC[ --noansi ] [ --shell | expression ]\fP
|
||||
.SH DESCRIPTION
|
||||
amath(1) features a case sensitive command line interface, internal
|
||||
IEEE 754 calculations with 15 significant digits, calculations with
|
||||
real and complex numbers, variables and user defined functions,
|
||||
logarithmic and exponential functions, trigonometric and hyperbolic
|
||||
function and selected mathematical constants and rounding functions.
|
||||
|
||||
.SH "Statements"
|
||||
.PP
|
||||
.SH Statements
|
||||
.nf
|
||||
clear Clear console window
|
||||
def Define function
|
||||
@@ -36,31 +52,23 @@ version Show version string
|
||||
memory Show internal memory usage
|
||||
exit Exit program
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Operators"
|
||||
.PP
|
||||
.SH Operators
|
||||
.nf
|
||||
+ Mathematical addition.
|
||||
- Mathematical subtraction.
|
||||
* Mathematical multiplication.
|
||||
/ Mathematical division.
|
||||
^ Mathematical exponentiation.
|
||||
= Assignment of variable values.
|
||||
| Absolute value of number.
|
||||
|
||||
.SH "Variables and constant"
|
||||
.PP
|
||||
+ Mathematical addition
|
||||
- Mathematical subtraction
|
||||
* Mathematical multiplication
|
||||
/ Mathematical division
|
||||
^ Mathematical exponentiation
|
||||
= Assignment of variable values
|
||||
| Absolute value of number
|
||||
.SH Variables and constant
|
||||
.nf
|
||||
pi Trigonometric constant
|
||||
e Euler's number
|
||||
i Imaginary unit
|
||||
ins Result of last calculation
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Base functions"
|
||||
.PP
|
||||
.SH Base functions
|
||||
.nf
|
||||
abs Absolute value of number
|
||||
sgn Mathematical signum function
|
||||
@@ -74,10 +82,7 @@ lb Binary logarithm function (base 2)
|
||||
ln Natural logarithm function (base e)
|
||||
lg Common logarithm function (base 10)
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Trigonometric functions"
|
||||
.PP
|
||||
.SH Trigonometric functions
|
||||
.nf
|
||||
sin Trigonometric sine function
|
||||
cos Trigonometric cosine function
|
||||
@@ -85,17 +90,20 @@ tan Trigonometric tangent function
|
||||
cot Trigonometric cotangent function
|
||||
sec Trigonometric secant function
|
||||
csc Trigonometric cosecant function
|
||||
crd Trigonometric chord function
|
||||
exsec Trigonometric exsecant function
|
||||
excsc Trigonometric excosecant function
|
||||
arcsin Inverse trigonometric sine function
|
||||
arccos Inverse trigonometric cosine function
|
||||
arctan Inverse trigonometric tangent function
|
||||
arccot Inverse trigonometric cotangent function
|
||||
arcsec Inverse trigonometric secant function
|
||||
arccsc Inverse trigonometric cosecant function
|
||||
arccrd Inverse trigonometric chord function
|
||||
arcexsec Inverse trigonometric exsecant function
|
||||
arcexcsc Inverse trigonometric excosecant function
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Hyperbolic functions"
|
||||
.PP
|
||||
.SH Hyperbolic functions
|
||||
.nf
|
||||
sinh Hyperbolic sine function
|
||||
cosh Hyperbolic cosine function
|
||||
@@ -110,10 +118,7 @@ arccoth Inverse hyperbolic cotangent function
|
||||
arcsech Inverse hyperbolic secant function
|
||||
arccsch Inverse hyperbolic cosecant function
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Early trigonometric functions"
|
||||
.PP
|
||||
.SH Early trigonometric functions
|
||||
.nf
|
||||
ver Versed sine function
|
||||
vcs Versed cosine function
|
||||
@@ -132,10 +137,7 @@ archvc Inverse haversed cosine function
|
||||
archcv Inverse hacoversed sine function
|
||||
archcc Inverse hacoversed cosine function
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Example script"
|
||||
.PP
|
||||
.SH Example script
|
||||
.nf
|
||||
round(1.5461);round(-1.5461);
|
||||
ceil(43.5461);ceil(-43.5461);
|
||||
@@ -143,10 +145,7 @@ floor(39.9531);floor(-39.9531);
|
||||
trunc(23.827);trunc(-23.827);
|
||||
sqrt(100);sqrt(52.23);
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Example script with functions"
|
||||
.PP
|
||||
.SH Example script with functions
|
||||
.nf
|
||||
f(x)=x*2+1;
|
||||
g(y)=y^2+y*1.5+2;
|
||||
@@ -154,10 +153,7 @@ a=2;b=3;c=a+b;
|
||||
vars;funcs;
|
||||
f(2.2);c+1.1;
|
||||
.fi
|
||||
.PP
|
||||
|
||||
.SH "Example script with complex numbers"
|
||||
.PP
|
||||
.SH Example script with complex numbers
|
||||
.nf
|
||||
cos(1+2i);
|
||||
sin(1+2i);
|
||||
@@ -166,8 +162,17 @@ coth(1+2i);
|
||||
sech(1+2i);
|
||||
csch(1+2i);
|
||||
.fi
|
||||
.SH HOMEPAGE
|
||||
https://amath.innolan.net/
|
||||
.SH AUTHORS
|
||||
.PP
|
||||
|
||||
.SH "See also"
|
||||
.PP
|
||||
amathc(3), amathr(3), amathi(3)
|
||||
Written by Carsten Sonne Larsen <cs@innolan.net>. The code in MemSet and
|
||||
MemCopy is derived from software contributed to Berkeley by Mike Hibler and
|
||||
Chris Torek. The code in complex calculations is derived from software
|
||||
written by Stephen L. Moshier.
|
||||
.SH COPYRIGHT
|
||||
Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
.br
|
||||
Copyright (c) 1990, 1993 The Regents of the University of California
|
||||
.SH SEE ALSO
|
||||
amathc(3), amathr(3), amathi(3)
|
||||
+6
-2210
File diff suppressed because it is too large
Load Diff
@@ -1,62 +0,0 @@
|
||||
all: flexcat
|
||||
|
||||
CFLAGS += -I. -Wall
|
||||
|
||||
asprintf.o: asprintf.c
|
||||
${CC} ${CFLAGS} -c asprintf.c
|
||||
|
||||
createcat.o: createcat.c
|
||||
${CC} ${CFLAGS} -c createcat.c
|
||||
|
||||
createcatsrc.o: createcatsrc.c
|
||||
${CC} ${CFLAGS} -c createcatsrc.c
|
||||
|
||||
createct.o: createct.c
|
||||
${CC} ${CFLAGS} -c createct.c
|
||||
|
||||
globals.o: globals.c
|
||||
${CC} ${CFLAGS} -c globals.c
|
||||
|
||||
locale_other.o: locale_other.c
|
||||
${CC} ${CFLAGS} -c locale_other.c
|
||||
|
||||
main.o: main.c
|
||||
${CC} ${CFLAGS} -c main.c
|
||||
|
||||
openlibs.o: openlibs.c
|
||||
${CC} ${CFLAGS} -c openlibs.c
|
||||
|
||||
readprefs.o: readprefs.c
|
||||
${CC} ${CFLAGS} -c readprefs.c
|
||||
|
||||
scancd.o: scancd.c
|
||||
${CC} ${CFLAGS} -c scancd.c
|
||||
|
||||
scanct.o: scanct.c
|
||||
${CC} ${CFLAGS} -c scanct.c
|
||||
|
||||
scanpo.o: scanpo.c
|
||||
${CC} ${CFLAGS} -c scanpo.c
|
||||
|
||||
showfuncs.o: showfuncs.c
|
||||
${CC} ${CFLAGS} -c showfuncs.c
|
||||
|
||||
strptime.o: strptime.c
|
||||
${CC} ${CFLAGS} -c strptime.c
|
||||
|
||||
swapfuncs.o: swapfuncs.c
|
||||
${CC} ${CFLAGS} -c swapfuncs.c
|
||||
|
||||
utils.o: utils.c
|
||||
${CC} ${CFLAGS} -c utils.c
|
||||
|
||||
vastubs.o: vastubs.c
|
||||
${CC} ${CFLAGS} -c vastubs.c
|
||||
|
||||
|
||||
flexcat: asprintf.o createcat.o createcatsrc.o createct.o globals.o locale_other.o main.o openlibs.o readprefs.o scancd.o scanct.o scanpo.o showfuncs.o strptime.o swapfuncs.o utils.o vastubs.o
|
||||
${CC} ${CFLAGS} -o flexcat asprintf.o createcat.o createcatsrc.o createct.o globals.o locale_other.o main.o openlibs.o readprefs.o scancd.o scanct.o scanpo.o showfuncs.o strptime.o swapfuncs.o utils.o vastubs.o -lm
|
||||
|
||||
clean:
|
||||
rm -f asprintf.o createcat.o createcatsrc.o createct.o globals.o locale_other.o main.o openlibs.o readprefs.o scancd.o scanct.o scanpo.o showfuncs.o strptime.o swapfuncs.o utils.o vastubs.o flexcat
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
version="1.7.0"
|
||||
version="1.8.2"
|
||||
|
||||
build_package () {
|
||||
|
||||
@@ -11,7 +11,7 @@ rm -f amath-${version}_$1.deb
|
||||
sh configure CFLAGS=$2
|
||||
make clean
|
||||
|
||||
echo "Building $3 bit package of amath ${version} for Debian ..."
|
||||
echo "Building $3 bit package of amath-dev ${version} for Debian ..."
|
||||
make
|
||||
mv amath amath.tmp
|
||||
|
||||
@@ -91,7 +91,7 @@ chmod 644 amath/usr/share/amath/*
|
||||
|
||||
# Create control file
|
||||
{
|
||||
echo "Package: amath"
|
||||
echo "Package: amath-dev"
|
||||
echo "Version: ${version}"
|
||||
echo "Architecture: $1"
|
||||
echo "Maintainer: Carsten Larsen <cs@innolan.net>"
|
||||
@@ -99,7 +99,7 @@ echo "Installed-Size: $4"
|
||||
echo "Depends: libc6"
|
||||
echo "Section: math"
|
||||
echo "Priority: optional"
|
||||
echo "Homepage: http://amath.innolan.net"
|
||||
echo "Homepage: https://amath.innolan.net"
|
||||
echo "Built-Using: gcc-5.4"
|
||||
echo "Description: Simple command line calculator"
|
||||
echo " Features a case sensitive command line interface, internal IEEE 754"
|
||||
@@ -113,8 +113,8 @@ chmod 0755 amath/DEBIAN/control
|
||||
# Create license file
|
||||
{
|
||||
echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"
|
||||
echo "Upstream-Name: amath"
|
||||
echo "Source: http://amath.innolan.net"
|
||||
echo "Upstream-Name: amath-dev"
|
||||
echo "Source: https://amath.innolan.net"
|
||||
echo
|
||||
echo "Files: *"
|
||||
echo "Copyright: 2014-2017 Carsten Sonne Larsen <cs@innolan.net>"
|
||||
@@ -191,7 +191,7 @@ echo "rm -f /usr/lib/libamathcplex.so.${version}"
|
||||
chmod 0755 amath/DEBIAN/postrm
|
||||
|
||||
fakeroot dpkg-deb --build amath
|
||||
mv amath.deb amath-${version}_$1.deb
|
||||
mv amath.deb amath-dev-${version}_$1.deb
|
||||
rm -Rf amath
|
||||
}
|
||||
|
||||
@@ -7,29 +7,29 @@ rm -Rf amath
|
||||
rm -Rf dist
|
||||
mkdir dist
|
||||
|
||||
./configure --disable-test --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
make clean
|
||||
make static
|
||||
mv amath dist/amath.000
|
||||
make clean
|
||||
./configure --disable-test --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath.020
|
||||
make clean
|
||||
./configure --disable-test --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath.030
|
||||
make clean
|
||||
|
||||
./configure --enable-test --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.000
|
||||
make clean
|
||||
./configure --enable-test --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.020
|
||||
make clean
|
||||
./configure --enable-test --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.030
|
||||
make clean
|
||||
@@ -61,3 +61,7 @@ date -Ru >dist/build_date
|
||||
|
||||
mv dist amath
|
||||
#lha-ac a amath.lha amath
|
||||
|
||||
# GCC 6.x
|
||||
#./configure --enable-test --cross-compile="/opt/m68k-amigaos6/bin/m68k-amigaos" CFLAGS="-m68000 -noixemul" LDFLAGS="-Xlinker --allow-multiple-definition"
|
||||
#make static
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#! /bin/sh
|
||||
|
||||
# DO NOT USE THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING !
|
||||
|
||||
version='1.8.2'
|
||||
stamp="201704220000"
|
||||
#stamp="201704110000"
|
||||
srcdir="amath-rc"
|
||||
distdir="amath-${version}"
|
||||
cd ..
|
||||
|
||||
rm -f amath-${version}.tar.gz
|
||||
rm -Rf amath-${version}
|
||||
|
||||
mkdir -m 775 ${distdir}
|
||||
mkdir -m 775 ${distdir}/src/
|
||||
mkdir -m 775 ${distdir}/src/clib/
|
||||
mkdir -m 775 ${distdir}/src/cplex/
|
||||
mkdir -m 775 ${distdir}/src/lib/
|
||||
mkdir -m 775 ${distdir}/src/loc/
|
||||
mkdir -m 775 ${distdir}/src/real/
|
||||
mkdir -m 775 ${distdir}/src/system/
|
||||
mkdir -m 775 ${distdir}/src/main/
|
||||
mkdir -m 775 ${distdir}/src/main/function
|
||||
mkdir -m 775 ${distdir}/src/main/statement/
|
||||
mkdir -m 775 ${distdir}/script/
|
||||
mkdir -m 775 ${distdir}/text/
|
||||
mkdir -m 775 ${distdir}/catalog/
|
||||
mkdir -m 775 ${distdir}/catalog/english/
|
||||
mkdir -m 775 ${distdir}/build/
|
||||
mkdir -m 775 ${distdir}/build/flexcat/
|
||||
|
||||
install -m 664 ${srcdir}/src/*.h ${distdir}/src/
|
||||
install -m 664 ${srcdir}/src/*.cpp ${distdir}/src/
|
||||
install -m 664 ${srcdir}/src/clib/* ${distdir}/src/clib/
|
||||
install -m 664 ${srcdir}/src/cplex/* ${distdir}/src/cplex/
|
||||
install -m 664 ${srcdir}/src/lib/* ${distdir}/src/lib/
|
||||
install -m 664 ${srcdir}/src/loc/* ${distdir}/src/loc/
|
||||
install -m 664 ${srcdir}/src/real/* ${distdir}/src/real/
|
||||
install -m 664 ${srcdir}/src/system/* ${distdir}/src/system/
|
||||
install -m 664 ${srcdir}/src/main/*.h ${distdir}/src/main/
|
||||
install -m 664 ${srcdir}/src/main/*.cpp ${distdir}/src/main/
|
||||
install -m 664 ${srcdir}/src/main/function/* ${distdir}/src/main/function/
|
||||
install -m 664 ${srcdir}/src/main/statement/* ${distdir}/src/main/statement/
|
||||
install -m 664 ${srcdir}/script/* ${distdir}/script/
|
||||
install -m 664 ${srcdir}/text/* ${distdir}/text/
|
||||
install -m 664 ${srcdir}/catalog/english/* ${distdir}/catalog/english/
|
||||
install -m 664 ${srcdir}/build/flexcat/* ${distdir}/build/flexcat/
|
||||
install -m 664 ${srcdir}/HISTORY ${distdir}/
|
||||
install -m 664 ${srcdir}/LICENSE ${distdir}/
|
||||
install -m 664 ${srcdir}/README ${distdir}/
|
||||
install -m 664 ${srcdir}/amath.1 ${distdir}/
|
||||
install -m 775 ${srcdir}/configure ${distdir}/
|
||||
install -m 775 ${srcdir}/builddist ${distdir}/
|
||||
install -m 775 ${srcdir}/buildwin ${distdir}/
|
||||
|
||||
chown -R 1000:1000 ${distdir}
|
||||
|
||||
for f in $(find ${distdir} -name '*'); do touch -amt ${stamp}.00 $f; done
|
||||
tar --numeric-owner -cvzf amath-${version}.tar.gz ${distdir}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
version="1.7.0"
|
||||
version="1.8.2"
|
||||
|
||||
echo "Building amath ${version} for Windows ..."
|
||||
|
||||
@@ -11,45 +11,31 @@ rm -Rf amath
|
||||
rm -Rf dist
|
||||
mkdir dist
|
||||
|
||||
./configure --enable-test --cross-compile="i686-w64-mingw32" CFLAGS="-D_WIN32" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
./configure --enable-test --cross-compile="i686-w64-mingw32" CFLAGS="-DWINDOWS" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
make clean
|
||||
make static
|
||||
mv amath dist/amath-${version}-x86.exe
|
||||
make clean
|
||||
|
||||
./configure --enable-test --cross-compile="x86_64-w64-mingw32" CFLAGS="-D_WIN32" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
./configure --enable-test --cross-compile="x86_64-w64-mingw32" CFLAGS="-DWINDOWS" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
make static
|
||||
mv amath dist/amath-${version}-x64.exe
|
||||
make clean
|
||||
|
||||
./configure --enable-test --cross-compile="i686-w64-mingw32" CFLAGS="-D_WIN32 -DANSICONSOLE" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
make static
|
||||
mv amath dist/amath-${version}-ansi-x86.exe
|
||||
make clean
|
||||
#cd dist
|
||||
#touch hashkeys.txt
|
||||
#sha1sum amath-${version}-x86.exe >>hashkeys.txt
|
||||
#sha1sum amath-${version}-x86.exe >>hashkeys.txt
|
||||
#sha256sum amath-${version}-x86.exe >>hashkeys.txt
|
||||
#sha256sum amath-${version}-x86.exe >>hashkeys.txt
|
||||
#cd ..
|
||||
|
||||
./configure --enable-test --cross-compile="x86_64-w64-mingw32" CFLAGS="-D_WIN32 -DANSICONSOLE" LDFLAGS="-static -static-libgcc -static-libstdc++"
|
||||
make static
|
||||
mv amath dist/amath-${version}-ansi-x64.exe
|
||||
make clean
|
||||
|
||||
cd dist
|
||||
touch hashkeys
|
||||
sha1sum amath-${version}-x86.exe >>hashkeys
|
||||
sha1sum amath-${version}-x86.exe >>hashkeys
|
||||
sha1sum amath-${version}-ansi-x86.exe >>hashkeys
|
||||
sha1sum amath-${version}-ansi-x64.exe >>hashkeys
|
||||
sha256sum amath-${version}-x86.exe >>hashkeys
|
||||
sha256sum amath-${version}-x86.exe >>hashkeys
|
||||
sha256sum amath-${version}-ansi-x86.exe >>hashkeys
|
||||
sha256sum amath-${version}-ansi-x64.exe >>hashkeys
|
||||
cd ..
|
||||
|
||||
cp LICENSE dist/
|
||||
cp HISTORY dist/
|
||||
tr '\n' '\r' <LICENSE >dist/license.txt
|
||||
tr '\n' '\r' <HISTORY >dist/changes.txt
|
||||
|
||||
mkdir dist/script
|
||||
cp script/* dist/script/
|
||||
date -Ru >dist/build_date
|
||||
date -Ru >dist/build.txt
|
||||
|
||||
mv dist amath
|
||||
zip -r amath-${version}.zip amath/*
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
## version $VER: amath-help.catalog 1.60 (09.04.2015) Danish
|
||||
## language dansk
|
||||
## codeset 0
|
||||
; #############################################################################
|
||||
; Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; * Redistributions of source code must retain the above copyright notice, this
|
||||
; list of conditions and the following disclaimer.
|
||||
;
|
||||
; * Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; #############################################################################
|
||||
; ### flexcat catalog/help.cd NEWCTFILE catalog/danish/amath-help.ct
|
||||
; flexcat catalog/help.cd catalog/danish/amath-help.ct CATALOG catalog/danish/amath-help.catalog
|
||||
; #############################################################################
|
||||
symzero
|
||||
Indtast kommando eller udtryk.#NEWLINE##SYNTAXHIGHLIGHT#Eksempel: 2+3-cos(3)#NORMALTEXT##NEWLINE# #NEWLINE#Mere hj�lp er tilg�ngelig i udvalgte omr�der#NEWLINE#-------------------------------------------------#NEWLINE#funktioner Grundl�ggende funktioner.#NEWLINE#trigo Trigonometriske funktioner.#NEWLINE#hyper Hyperbolske funktioner.#NEWLINE#kompleks Komplekse tal.#NEWLINE#kommandoer Underst�ttede kommondoer.#NEWLINE#operatorer Underst�ttede operatorer.#NEWLINE#-------------------------------------------------#NEWLINE##SYNTAXHIGHLIGHT#Eksemple: hj�lp trigo#NEWLINE#
|
||||
symoperator
|
||||
-------------------------------------------------#NEWLINE# + Matematik addition.#NEWLINE# - Matematik subtraktion.#NEWLINE# * Matematik multiplikation.#NEWLINE# / Matematik division.#NEWLINE# ^ Matematik potensopl�ftning.#NEWLINE# = Tildeling af variabel v�rdi.#NEWLINE# | Absolutte eller numerisk v�rdi.#NEWLINE#-------------------------------------------------#NEWLINE#
|
||||
symfunction
|
||||
-------------------------------------------------#NEWLINE#abs Absolutte eller numerisk v�rdi.#NEWLINE#sgn Matematik signum funktion.#NEWLINE#round Afrund til n�rmeste heltal.#NEWLINE#trunc Fjern decimaler.#NEWLINE#floor Afrund i positiv retning.#NEWLINE#ceil Afrund i negativ retning.#NEWLINE#sqrt Kvadratrodsfunktion (exponent 1/2).#NEWLINE#cbrt Kubikrods (exponent 1/3).#NEWLINE#lb Bin�r logaritme funktion (grundtal 2).#NEWLINE#ln Naturlig logaritme funktion (grundtal e).#NEWLINE#lg 10-talslogaritme funktion (grundtal 10).#NEWLINE#-------------------------------------------------#NEWLINE##SYNTAXHIGHLIGHT#Eksempel: round(1.55)#NORMALTEXT##NEWLINE#
|
||||
symtrigon
|
||||
-------------------------------------------------#NEWLINE#sin Trigonometrisk sinus funktion.#NEWLINE#cos Trigonometrisk cosinus funktion.#NEWLINE#tan Trigonometrisk tangent funktion.#NEWLINE#cot Trigonometrisk cotangent funktion.#NEWLINE#sec Trigonometrisk secant funktion.#NEWLINE#csc Trigonometrisk cosecant funktion.#NEWLINE#asin Invers trigonometrisk sinus funktion.#NEWLINE#acos Invers trigonometrisk cosinus funktion.#NEWLINE#atan Invers trigonometrisk tangent funktion.#NEWLINE#acot Invers trigonometrisk cotangent funktion.#NEWLINE#asec Invers trigonometrisk secant funktion.#NEWLINE#acsc Invers trigonometrisk cosecant funktion.#NEWLINE#-------------------------------------------------#NEWLINE#Inverse funktioner kan prefixes med ar eller arc #NEWLINE#i stedet for a.#NEWLINE#
|
||||
symhyper
|
||||
-------------------------------------------------#NEWLINE#sinh Hyperbolsk sinus funktion.#NEWLINE#cosh Hyperbolsk cosinus funktion.#NEWLINE#tanh Hyperbolsk tangent funktion.#NEWLINE#coth Hyperbolsk cotangent funktion.#NEWLINE#sech Hyperbolsk secant funktion.#NEWLINE#csch Hyperbolsk cosecant funktion. #NEWLINE#asinh Invers hyperbolsk sinus funktion.#NEWLINE#acosh Invers hyperbolsk cosinus funktion.#NEWLINE#atanh Invers hyperbolsk tangent funktion.#NEWLINE#acoth Invers hyperbolsk cotangent funktion.#NEWLINE#asech Invers hyperbolsk secant funktion.#NEWLINE#acsch Invers hyperbolsk cosecant funktion.#NEWLINE#-------------------------------------------------#NEWLINE#Inverse funktioner kan prefixes med ar eller arc #NEWLINE#i stedet for a.#NEWLINE#
|
||||
symearly
|
||||
TODO-------------------------------------------------#NEWLINE#ver Versed sine function.#NEWLINE#vcs Versed cosine function.#NEWLINE#cvs Coversed sine function.#NEWLINE#cvc Coversed cosine function.#NEWLINE#hv Haversed sine function.#NEWLINE#hvc Haversed cosine function.#NEWLINE#hcv Hacoversed sine function.#NEWLINE#hcc Hacoversed cosine function.#NEWLINE#aver Inverse versed sine function.#NEWLINE#avcs Inverse versed cosine function.#NEWLINE#acvs Inverse coversed sine function.#NEWLINE#acvc Inverse coversed cosine function.#NEWLINE#ahv Inverse haversed sine function.#NEWLINE#ahvc Inverse haversed cosine function.#NEWLINE#ahcv Inverse hacoversed sine function.#NEWLINE#ahcc Inverse hacoversed cosine function.#NEWLINE#-------------------------------------------------#NEWLINE#Inverse functions can be prefixed with ar or arc #NEWLINE#instead of a.#NEWLINE#
|
||||
symcomplex
|
||||
Udtryk med komplekse tal skrives ved at angive i#NEWLINE#sammen med den imagin�re talv�rdi. Komplekse tal#NEWLINE#kan blandes med reelle tal.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: 2+3i#NEWLINE#Eksempel: 2+3.2i*cos(-1i)+5/7#NEWLINE#
|
||||
symclear
|
||||
Ryd kommandoen sletter alt tekst i konsol vinduet.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: ryd#NEWLINE#
|
||||
symdef
|
||||
Definer kommandoen bruges til at definere funktioner med. Det er ikke#NEWLINE#strengt n�dvendigt at angive kommandoen, n�r en funktion skal defineres.#NEWLINE#Allerede definerede funktioner kan vises med kommandoen #SYNTAXHIGHLIGHT#funtioner#NORMAL#.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: definer f(x)=2*x+3#NEWLINE#Alternativ syntaks: f(x)=2*x+3#NEWLINE#
|
||||
; Help for delete statement
|
||||
symdelete
|
||||
The delete statement can delete variable and funktions. To delete a#NEWLINE#single variable or funktions use the name of the funktion or variable.#NEWLINE#To delete all funktions or variables specify either the variable or#NEWLINE#funktion keyword.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: delete f(x)#NEWLINE#Syntaks: delete variables#NEWLINE#
|
||||
; Help for digits statement
|
||||
symdigits
|
||||
The digits statement defines the displayed number of significant digits.#NEWLINE#To show current configuration use the digits statement without specifying#NEWLINE#the number.#NEWLINE# #SYNTAXHIGHLIGHT#Syntaks: digits 7#NEWLINE#
|
||||
; Help for eval statement
|
||||
symeval
|
||||
The eval statement evaluates an expression. When evaluating an expression#NEWLINE#it is possible to omit the eval keyword.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: eval 2.4*x+3.2#NEWLINE#Optional syntax: 2.4*x+3.2#NEWLINE#
|
||||
; Help for execute statement
|
||||
symexecute
|
||||
The execute statement reads the content of a file and execute all statements.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: execute "savedfile"#NEWLINE#
|
||||
; Help for input statement
|
||||
syminput
|
||||
The input statement either changes or shows the how numeral input is interpreted.#NEWLINE#Possible input systems are: binary, octal, decimal and hexadecimal. Default is#NEWLINE#decimal. To use positional systems with other bases specify the base number.#NEWLINE#Numeral output system can be modified using the output statement.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: input hexadecimal#NEWLINE#Syntaks: input 4#NEWLINE#
|
||||
; Help for help statement
|
||||
symhelp
|
||||
The help statement can be used to display help about topics and statements.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: help variables#NEWLINE#
|
||||
; Help for output statement
|
||||
symoutput
|
||||
The output statement either changes or shows the how numeral output is shown.#NEWLINE#Possible output systems are: binary, octal, decimal and hexadecimal. Default#NEWLINE#is decimal. To use positional systems with other bases specify the base number.#NEWLINE#Numeral input system can be modified using the input statement.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: output octal#NEWLINE#
|
||||
; Help for list statement
|
||||
symlist
|
||||
No description is available for the list statement.#NEWLINE#
|
||||
symshow
|
||||
Vis kommandoen kan bruges til at vise indholdet af en fil, der �nskes k�rt.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: vis "mitscript"#NEWLINE#
|
||||
; Help for load statement
|
||||
symload
|
||||
The load statement retrieves a set of defined variables and funktions from#NEWLINE#a file. Variables and funktions can be saved using the save statement.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: load "savedwork"#NEWLINE#
|
||||
; Help for save statement
|
||||
symsave
|
||||
Med gem kommando kan variabler og funktioner i hukommelsen gemmes til en fil.#NEWLINE#Gemte variabler og funktion kan indl�stet igen med #SYNTAXHIGHLIGHT#hent#NORMAL# kommandoen.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: gem "mitarbejde"#NEWLINE#
|
||||
symversion
|
||||
Viser hvilken version af amath der k�rer.#NEWLINE#
|
||||
symabout
|
||||
TODOShow various information about the running version of amath.#NEWLINE#
|
||||
symlicense
|
||||
TODOShow license details.#NEWLINE#
|
||||
symmem
|
||||
Viser internt hukommelsesforbrug. Programkoden er ikke medregnet.#NEWLINE#
|
||||
; Help for prefs statement
|
||||
symprefs
|
||||
There is no help for prefs statement now.#NEWLINE#
|
||||
symvariable
|
||||
Variabler kommandoen viser en list af definerede variabler i hukommelsen.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: variabler#NEWLINE#Alternativ syntaks: var#NEWLINE#
|
||||
symexit
|
||||
Afslut kommandoen lukker amath programmet.#NEWLINE##SYNTAXHIGHLIGHT#Syntaks: afslut#NEWLINE#
|
||||
; Help for constant epsilon
|
||||
syme
|
||||
Euler's number is base of the exponential funktion which equals its own#NEWLINE#derivative. It is approximately equal to 2.71828.#NEWLINE##SYNTAXHIGHLIGHT#Example: ln(e)#NEWLINE#
|
||||
; Help for constant pi
|
||||
sympi
|
||||
Pi is the ratio of the circumference of a circle to its diameter. Being an#NEWLINE#irrational number, pi cannot be expressed exactly as a common fraction.#NEWLINE#The value of pi is commonly approximated as #SYNTAXHIGHLIGHT#3.14159#NORMALTEXT#.#NEWLINE#
|
||||
symi
|
||||
Den imagin�re enhen refereres og angives almindelig vis som i.#NEWLINE#Den imagin�re enhen et tal, som n�r det ganges med sig selv,#NEWLINE#giver resultatet -1.#NEWLINE#
|
||||
symins
|
||||
Den sidst udregnede v�rdi kan benyttes i n�ste udtryk ved hj�lp af #SYNTAXHIGHLIGHT#ins#NORMAL# variablen.#NEWLINE##SYNTAXHIGHLIGHT#Eksemple: ins*0,25#NEWLINE#
|
||||
symbin
|
||||
Der er ikke nogen hj�lp tilg�ngelig om bin�r n�gleordet.#NEWLINE
|
||||
symoct
|
||||
Der er ikke nogen hj�lp tilg�ngelig om oktal n�gleordet.#NEWLINE
|
||||
symdec
|
||||
Der er ikke nogen hj�lp tilg�ngelig om decimal n�gleordet.#NEWLINE
|
||||
symhex
|
||||
Der er ikke nogen hj�lp tilg�ngelig om hexadecimal n�gleordet.#NEWLINE
|
||||
@@ -1,121 +0,0 @@
|
||||
## version $VER: amath-ident.catalog 1.60 (08.04.2015) Danish
|
||||
## language dansk
|
||||
## codeset 0
|
||||
; #############################################################################
|
||||
; ## Help texts for built-in functions in amath
|
||||
; ## ------------------------------------------
|
||||
; ##
|
||||
; ## This file is published under Creative Common License. See:
|
||||
; ## http://creativecommons.org/licenses/by-sa/3.0/
|
||||
; ## Parts of the content came from wikipedia.org
|
||||
; #############################################################################
|
||||
abs
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sgn
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
round
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
trunc
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
floor
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
ceil
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sqr
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
cbr
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
lb
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
ln
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
lg
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sin
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
cos
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
tan
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
cot
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sec
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
csc
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
asin
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acos
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
atan
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acot
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
asec
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acsc
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sinh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
cosh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
tanh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
coth
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
sech
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
csch
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
asinh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acosh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
atanh
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acoth
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
asech
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
acsch
|
||||
Der er ikke nogen hj�lp tilg�ngelig om den funktion.#NEWLINE#
|
||||
ver
|
||||
The versed sine is an early appearing trigonometric function.#NEWLINE#It is equal to one minus the cosine.#NEWLINE#ver(x) = 1 - cos(x)#NEWLINE#
|
||||
vcs
|
||||
The versed cosine is an early appearing trigonometric function.#NEWLINE#It is equal to one plus the cosine.#NEWLINE#ver(x) = 1 + cos(x)#NEWLINE#
|
||||
cvs
|
||||
The coversed sine is an early appearing trigonometric function.#NEWLINE#It is equal to one minus the sine.#NEWLINE#ver(x) = 1 - sin(x)#NEWLINE#
|
||||
cvc
|
||||
The coversed cosine is an early appearing trigonometric function.#NEWLINE#It is equal to one plus the sine.#NEWLINE#cvc(x) = 1 + sin(x)#NEWLINE#
|
||||
hv
|
||||
No help is available for the haversed sine function.#NEWLINE#
|
||||
hvc
|
||||
No help is available for the haversed cosine function.#NEWLINE#
|
||||
hcv
|
||||
No help is available for the hacoversed sine function.#NEWLINE#
|
||||
hcc
|
||||
No help is available for the hacoversed cosine function.#NEWLINE#
|
||||
aver
|
||||
No help is available for this function.#NEWLINE#
|
||||
avcs
|
||||
No help is available for this function.#NEWLINE#
|
||||
acvs
|
||||
No help is available for this function.#NEWLINE#
|
||||
acvc
|
||||
No help is available for this function.#NEWLINE#
|
||||
ahv
|
||||
No help is available for this function.#NEWLINE#
|
||||
ahvc
|
||||
No help is available for this function.#NEWLINE#
|
||||
ahcv
|
||||
No help is available for this function.#NEWLINE#
|
||||
ahcc
|
||||
No help is available for this function.#NEWLINE#
|
||||
exsec
|
||||
No help is available for this function.#NEWLINE#
|
||||
excsc
|
||||
No help is available for this function.#NEWLINE#
|
||||
aexsec
|
||||
No help is available for this function.#NEWLINE#
|
||||
aexcsc
|
||||
No help is available for this function.#NEWLINE#
|
||||
@@ -1,164 +0,0 @@
|
||||
## version $VER: amath-keyword.catalog 1.60 (08.04.2015) Danish
|
||||
## language dansk
|
||||
## codeset 0
|
||||
;#############################################################################
|
||||
; Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; * Redistributions of source code must retain the above copyright notice, this
|
||||
; list of conditions and the following disclaimer.
|
||||
;
|
||||
; * Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;#############################################################################
|
||||
;######### ClearStatement
|
||||
clear
|
||||
ryd
|
||||
;######### FunctionDefinition statement
|
||||
def
|
||||
definer
|
||||
;######### DeleteStatement and keyword
|
||||
delete
|
||||
slet
|
||||
;######### Eulers Number keyword
|
||||
e
|
||||
e
|
||||
;######### Complex i keyword
|
||||
i
|
||||
i
|
||||
;######### pi keyword
|
||||
pi
|
||||
pi
|
||||
;######### ins variable keyword
|
||||
ins
|
||||
ins
|
||||
;######### EvalStatement
|
||||
eval
|
||||
beregn
|
||||
;######### DrawStatement
|
||||
draw
|
||||
tegn
|
||||
;######### PlotStatement
|
||||
plot
|
||||
plot
|
||||
;######### ExecuteStatement
|
||||
execute
|
||||
k�r
|
||||
;######### ExitStatement
|
||||
exit
|
||||
afslut
|
||||
quit
|
||||
slut
|
||||
;######### Statements keyword
|
||||
statements
|
||||
kommandoer
|
||||
;######### Operators keyword
|
||||
operators
|
||||
operatorer
|
||||
;######### Complex keyword
|
||||
complex
|
||||
kompleks
|
||||
;######### Function keyword
|
||||
funcs
|
||||
funk
|
||||
functions
|
||||
funktioner
|
||||
;######### Trigonometric keyword
|
||||
trigon
|
||||
trigo
|
||||
trigonometric
|
||||
trigonometri
|
||||
;######### Hyperbolic keyword
|
||||
hyper
|
||||
hyper
|
||||
hyperbolic
|
||||
hyperbolsk
|
||||
;######### Early keyword
|
||||
early
|
||||
tidlig
|
||||
;######### HelpStatement
|
||||
help
|
||||
hj�lp
|
||||
;######### PromptStatement
|
||||
prompt
|
||||
prompt
|
||||
;######### VersionStatement
|
||||
version
|
||||
version
|
||||
;######### MemoryStatement
|
||||
mem
|
||||
hukommelse
|
||||
memory
|
||||
hukommelse
|
||||
;######### PrefsStatement
|
||||
prefs
|
||||
pr�f
|
||||
preferences
|
||||
pr�ferencer
|
||||
;######### ListStatement and keyword
|
||||
list
|
||||
list
|
||||
;######### LoadStatement and keyword
|
||||
load
|
||||
hent
|
||||
;######### SaveStatement and keyword
|
||||
save
|
||||
gem
|
||||
;######### ShowStatement and keyword
|
||||
show
|
||||
vis
|
||||
;######### ListVariablesStatement and keyword
|
||||
vars
|
||||
var
|
||||
variables
|
||||
variabler
|
||||
;######### DigitsStatement
|
||||
digits
|
||||
cifre
|
||||
;######### InputStatement
|
||||
input
|
||||
ind
|
||||
;######### OutputStatement
|
||||
output
|
||||
ud
|
||||
;######### Binary keyword
|
||||
bin
|
||||
bin
|
||||
binary
|
||||
bin�r
|
||||
;######### Octal keyword
|
||||
oct
|
||||
okt
|
||||
octal
|
||||
oktal
|
||||
;######### Decimal keyword
|
||||
dec
|
||||
dec
|
||||
decimal
|
||||
decimal
|
||||
;######### Hexadecimal keyword
|
||||
hex
|
||||
hex
|
||||
hexadecimal
|
||||
hexadecimal
|
||||
;######### AboutStatement and keyword
|
||||
about
|
||||
om
|
||||
;######### LicenseStatement and keyword
|
||||
license
|
||||
lisens
|
||||
@@ -1,136 +0,0 @@
|
||||
## version $VER: amath-text.catalog 1.60 (08.04.2015) Danish
|
||||
## language dansk
|
||||
## codeset 0
|
||||
; #############################################################################
|
||||
; Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; * Redistributions of source code must retain the above copyright notice, this
|
||||
; list of conditions and the following disclaimer.
|
||||
;
|
||||
; * Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
; #############################################################################
|
||||
INTROMSG
|
||||
#NORMALTEXT##BOLD##STARTMSG##NEWLINE##NORMALTEXT##COLOR02#Skriv hj�lp for at f� vist uddybende information.#NEWLINE#
|
||||
STATEMENTLINE
|
||||
---------------------------------------------------------#NEWLINE#
|
||||
STATEMENTCLEAR
|
||||
clear Clear console window.#NEWLINE#
|
||||
STATEMENTDEF
|
||||
def Define function.#NEWLINE#
|
||||
STATEMENTDELETE
|
||||
delete Delete variable or function.#NEWLINE#
|
||||
STATEMENTDIGITS
|
||||
digits Set number of significant digits.#NEWLINE#
|
||||
STATEMENTEVAL
|
||||
eval Evaluate arithmetic expression.#NEWLINE#
|
||||
STATEMENTEXECUTE
|
||||
execute Execute statements in a file.#NEWLINE#
|
||||
STATEMENTFUNCS
|
||||
functions Show list of user defined functions.#NEWLINE#
|
||||
STATEMENTINPUT
|
||||
input Change numeral input system.#NEWLINE#
|
||||
STATEMENTHELP
|
||||
help Show basic help text.#NEWLINE#
|
||||
STATEMENTOUTPUT
|
||||
output Change numeral output system.#NEWLINE#
|
||||
STATEMENTLIST
|
||||
list Show content of a directory.#NEWLINE#
|
||||
STATEMENTSHOW
|
||||
show Show content of a file.#NEWLINE#
|
||||
STATEMENTLOAD
|
||||
load Load variable and functions from file.#NEWLINE#
|
||||
STATEMENTSAVE
|
||||
save Save variable and functions to file.#NEWLINE#
|
||||
STATEMENTVARS
|
||||
variables Show list of variables.#NEWLINE#
|
||||
STATEMENTVERSION
|
||||
version Show version string.#NEWLINE#
|
||||
STATEMENTMEMORY
|
||||
memory Show internal memory usage.#NEWLINE#
|
||||
STATEMENTEXIT
|
||||
exit Exit program.#NEWLINE#
|
||||
STATEMENTFOOTER
|
||||
The def and eval statements are optional. Functions and#NEWLINE#variables statements can be shorten to funcs and vars.#NEWLINE#
|
||||
TXTLISTDIRHEADER
|
||||
Type Navn#NEWLINE#-----------------------------------------------#NEWLINE#
|
||||
TXTLISTDIRTFILE
|
||||
[fil]
|
||||
TXTLISTDIRTDIR
|
||||
[mappe]
|
||||
TXTLISTDIRTUNKNOWN
|
||||
[ukendt]
|
||||
TXTMEMBLOCKS
|
||||
Allokerede blokke: #SPACE#
|
||||
TXTMEMSIZE
|
||||
Hukommelsesforbrug:#SPACE#
|
||||
TXTMEMMAXSIZE
|
||||
H�jeste forbrug: #SPACE#
|
||||
HELPNOHELP
|
||||
Der er ingen hj�lp tilg�ngelig om det emne.#NEWLINE#
|
||||
HELPSYNTAX
|
||||
Syntaktiske fejl:#SPACE#
|
||||
HELPUERROR
|
||||
Uventet fejl:#SPACE#
|
||||
HELPVARNDEF
|
||||
Variablen er ikke defineret:#SPACE#
|
||||
HELPFUNNDEF
|
||||
Funktionen er ikke defineret:#SPACE#
|
||||
HELPFUNRDEF
|
||||
Funktionen er allerede defineret:#SPACE#
|
||||
HELPPNUMERA
|
||||
Grundtallet skal v�re mellem 2 og 32:#SPACE#
|
||||
HELPPDIGITS
|
||||
Antal betydende cifre skal v�re mellem 0 og 15:#SPACE#
|
||||
HELPINPUSHOW
|
||||
Talsystemet n�r computeren l�ser ind er#SPACE#
|
||||
HELPOUTPSHOW
|
||||
Talsystemet n�r computeren skriver ud er#SPACE#
|
||||
HELPINPUSETT
|
||||
Talsystemet ved indl�sning �ndret til#SPACE#
|
||||
HELPOUTPSETT
|
||||
Talsystemet ved udskrivning �ndret til#SPACE#
|
||||
HELPDIGISETT
|
||||
Antal betydende cifre �ndret til#SPACE#
|
||||
HELPDIGISHOW
|
||||
Antal betydende cifre der vises er#SPACE#
|
||||
HELPVARSNDEF
|
||||
Der er ikke defineret nogle variabler.#NEWLINE#
|
||||
HELPFUNCNDEF
|
||||
Der er ikke defineret nogle funktioner.#NEWLINE#
|
||||
HELPLOADSUCC
|
||||
Variabler og funktioner indl�st fra fil.#NEWLINE#
|
||||
HELPSAVESUCC
|
||||
Variabler og funktioner gemt til fil.#NEWLINE#
|
||||
HELPSAVEFAIL
|
||||
Kan ikke gemme fil.#NEWLINE#
|
||||
HELPSAVENOTH
|
||||
Der er ikke noget og gemme.#NEWLINE#
|
||||
HELPPREFLOAD
|
||||
Pr�ferencer blev indl�st.#NEWLINE#
|
||||
HELPPREFNOLO
|
||||
Kunne ikke indl�ses pr�ferencer.#NEWLINE#
|
||||
HELPPREFSAVE
|
||||
Pr�ferencer blev gemt.#NEWLINE#
|
||||
HELPPREFNOSA
|
||||
Kunne ikke gemme pr�ferencer.#NEWLINE#
|
||||
MSGNODIR
|
||||
Mappen kan ikke �bnes:#SPACE#
|
||||
MSGNOFILE
|
||||
Filen kan ikke �bnes.#NEWLINE#
|
||||
@@ -27,68 +27,167 @@
|
||||
|
||||
set -e
|
||||
|
||||
version="1.7.0"
|
||||
version="1.8.2"
|
||||
|
||||
clang=false
|
||||
debugsym=false
|
||||
regtest=true
|
||||
openlibm=false
|
||||
stdlibm=false
|
||||
stdlibc=false
|
||||
useldconfig=false
|
||||
fpic=false
|
||||
|
||||
prefix="/usr"
|
||||
pkgconfigdir="lib/pkgconfig"
|
||||
mandir="share/man"
|
||||
cflags=""
|
||||
cxxflags=""
|
||||
ldflags=""
|
||||
gcclib="-lstdc++"
|
||||
libm=""
|
||||
libc=""
|
||||
|
||||
for arg in "$@"; do
|
||||
unknown=true
|
||||
case "$arg" in
|
||||
--prefix=*)
|
||||
prefix=`echo $arg | sed 's/--prefix=//'`
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--pkgconfig=*)
|
||||
pkgconfigdir=`echo $arg | sed 's/--pkgconfig=//'`
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--mandir=*)
|
||||
mandir=`echo $arg | sed 's/--mandir=//'`
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--man-dir=*)
|
||||
mandir=`echo $arg | sed 's/--mandir=//'`
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--doc-dir=*)
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--cross-compile=*)
|
||||
crosscompile=`echo $arg | sed 's/--cross-compile=//'`
|
||||
crosscompile="${crosscompile}-"
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
CFLAGS=*)
|
||||
cflags=`echo $arg | sed 's/CFLAGS=//'`
|
||||
cflags="${cflags} "
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
CXXFLAGS=*)
|
||||
cxxflags=`echo $arg | sed 's/CXXFLAGS=//'`
|
||||
cxxflags="${cxxflags} "
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
LDFLAGS=*)
|
||||
ldflags=`echo $arg | sed 's/LDFLAGS=//'`
|
||||
ldflags="${ldflags} "
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-clang)
|
||||
clang=true;;
|
||||
clang=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--disable-clang)
|
||||
clang=false;;
|
||||
clang=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-ldconfig)
|
||||
useldconfig=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--disable-ldconfig)
|
||||
useldconfig=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-pic)
|
||||
fpic=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--disable-pic)
|
||||
fpic=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-debug)
|
||||
debugsym=true;;
|
||||
debugsym=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--disable-debug)
|
||||
debugsym=false;;
|
||||
debugsym=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-test)
|
||||
regtest=true;;
|
||||
--disable-test)
|
||||
regtest=false;;
|
||||
regtest=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--enable-stdc++)
|
||||
gcclib="-lstdc++";;
|
||||
--disable-stdc++)
|
||||
gcclib="";;
|
||||
--disable-test)
|
||||
regtest=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--with-libm)
|
||||
stdlibm=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--without-libm)
|
||||
stdlibm=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--with-openlibm)
|
||||
openlibm=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--without-openlibm)
|
||||
openlibm=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--with-stdc++)
|
||||
gcclib="-lstdc++"
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--without-stdc++)
|
||||
gcclib=""
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--with-libc)
|
||||
stdlibc=true
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--without-libc)
|
||||
stdlibc=false
|
||||
unknown=false
|
||||
;;
|
||||
|
||||
--help)
|
||||
echo "amath configure script ${version}"
|
||||
@@ -97,6 +196,7 @@ for arg in "$@"; do
|
||||
echo 'options:'
|
||||
echo ' --prefix=<path>: installation prefix'
|
||||
echo ' --pkgconfig=<path>: pkg-config path (without prefix)'
|
||||
echo ' --mandir=<path>: manpage path (without prefix)'
|
||||
echo ' --cross-compile=<prefix>: cross compiler prefix'
|
||||
echo ' --enable-debug: include debug symbols'
|
||||
echo ' --disable-debug: do not include debug symbols'
|
||||
@@ -104,17 +204,31 @@ for arg in "$@"; do
|
||||
echo ' --disable-test: do not include regression test'
|
||||
echo ' --enable-clang: build with clang compiler'
|
||||
echo ' --disable-clang: do not build with clang compiler'
|
||||
echo ' --enable-stdc++: link with stdc++ library'
|
||||
echo ' --disable-stdc++: do not link with stdc++ library'
|
||||
echo ' --enable-ldconfig: use ldconfig to registre libraries'
|
||||
echo ' --disable-ldconfig: do not use ldconfig to registre libraries'
|
||||
echo ' --enable-pic: build with Position Independent Code (-fPIC)'
|
||||
echo ' --disable-pic: do not build static libraries with Position Independent Code'
|
||||
echo ' --with-libm: link with libm library (-lm)'
|
||||
echo ' --without-libm: do not link with libm library'
|
||||
echo ' --with-openlibm: link with openlibm library (-lopenlibm)'
|
||||
echo ' --without-openlibm: do not link with openlibm library'
|
||||
echo ' --with-stdc++: link with stdc++ library (-lstdc++)'
|
||||
echo ' --without-stdc++: do not link with stdc++ library'
|
||||
echo ' --with-libc: explicit link with libc library (-lc)'
|
||||
echo ' --without-libc: do not link with libc library'
|
||||
echo
|
||||
echo ' CFLAGS=<flags>: additional compiler flags'
|
||||
echo ' CXXFLAGS=<flags>: additional compiler flags'
|
||||
echo ' LDFLAGS=<flags>: additional linker flags'
|
||||
echo
|
||||
echo 'all invalid options are silently ignored'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if $unknown; then
|
||||
echo "Invalid option $arg"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if $clang; then
|
||||
@@ -135,12 +249,46 @@ if $debugsym; then
|
||||
appop="-O0 -g"
|
||||
libop="-O0 -g"
|
||||
exestrip=""
|
||||
debugflag="-DDEBUG "
|
||||
else
|
||||
appop="-O2"
|
||||
libop="-O3"
|
||||
exestrip="-s"
|
||||
debugflag=""
|
||||
fi
|
||||
|
||||
dlibm=false
|
||||
mflags=""
|
||||
if $stdlibm; then
|
||||
libm="-lm "
|
||||
mflags="-DLIBM "
|
||||
dlibm=true
|
||||
fi
|
||||
|
||||
if $openlibm; then
|
||||
libm="-lopenlibm "
|
||||
mflags="-DLIBM "
|
||||
dlibm=true
|
||||
fi
|
||||
|
||||
if $useldconfig; then
|
||||
soverion=".${version}"
|
||||
else
|
||||
soverion=""
|
||||
fi
|
||||
|
||||
if $stdlibc; then
|
||||
gcclib="${gcclib} -lc"
|
||||
libc="-lc"
|
||||
fi
|
||||
|
||||
if $fpic; then
|
||||
fPIC=" -fPIC"
|
||||
else
|
||||
fPIC=""
|
||||
fi
|
||||
|
||||
cflags="${cflags}${debugflag}${mflags}"
|
||||
cxxflags="${cflags} ${cxxflags}"
|
||||
|
||||
APPSRCS='
|
||||
@@ -161,28 +309,29 @@ SYSSRCS='
|
||||
console.cpp
|
||||
console_amiga.cpp
|
||||
console_stdc.cpp
|
||||
console_termios.cpp
|
||||
console_windows.cpp
|
||||
filesystem_amiga.cpp
|
||||
filesystem_stdc.cpp
|
||||
language.cpp
|
||||
language_amiga.cpp
|
||||
language_posix.cpp
|
||||
language_stdc.cpp
|
||||
preferences.cpp
|
||||
preferences_amiga.cpp
|
||||
preferences_stdc.cpp
|
||||
proc_amiga.cpp
|
||||
program.cpp
|
||||
program_amiga.cpp
|
||||
program_haiku.cpp
|
||||
program_stdc.cpp
|
||||
program_test.cpp
|
||||
task_amiga.cpp
|
||||
task_stdc.cpp
|
||||
window_amiga.cpp
|
||||
window_haiku.cpp
|
||||
'
|
||||
FUNCTIONSRC='
|
||||
absolute.cpp
|
||||
aexcosecant.cpp
|
||||
aexsecant.cpp
|
||||
arcchord.cpp
|
||||
arccos.cpp
|
||||
arcsin.cpp
|
||||
arctan.cpp
|
||||
@@ -198,6 +347,7 @@ archaversine.cpp
|
||||
arcvercosine.cpp
|
||||
arcversine.cpp
|
||||
ceil.cpp
|
||||
chord.cpp
|
||||
cosecant.cpp
|
||||
cosine.cpp
|
||||
cotangent.cpp
|
||||
@@ -268,38 +418,34 @@ version.cpp
|
||||
'
|
||||
LIBAPPSRCS='
|
||||
aengine.cpp
|
||||
bigint.cpp
|
||||
charbuf.cpp
|
||||
integer.cpp
|
||||
cplex.cpp
|
||||
nnumb.cpp
|
||||
ntext.cpp
|
||||
ntextd.cpp
|
||||
ntextp.cpp
|
||||
real.cpp
|
||||
'
|
||||
LIBREALSRCS='
|
||||
acos.c
|
||||
acosh.c
|
||||
acvs.c
|
||||
ahv.c
|
||||
ahvc.c
|
||||
asin.c
|
||||
asinh.c
|
||||
atan.c
|
||||
atan2.c
|
||||
atanh.c
|
||||
aver.c
|
||||
cbrt.c
|
||||
ceil.c
|
||||
copysign.c
|
||||
csign.c
|
||||
cos.c
|
||||
cosh.c
|
||||
exp.c
|
||||
expm1.c
|
||||
fabs.c
|
||||
finite.c
|
||||
floor.c
|
||||
fmod.c
|
||||
hypot.c
|
||||
isnan.c
|
||||
kcos.c
|
||||
kremp2.c
|
||||
ksin.c
|
||||
@@ -318,39 +464,79 @@ tan.c
|
||||
tanh.c
|
||||
trunc.c
|
||||
'
|
||||
LIBREAL2SRCS='
|
||||
acot.c
|
||||
acoth.c
|
||||
acrd.c
|
||||
acsc.c
|
||||
acsch.c
|
||||
acvc.c
|
||||
acvs.c
|
||||
aexc.c
|
||||
aexs.c
|
||||
ahcc.c
|
||||
ahcv.c
|
||||
ahv.c
|
||||
ahvc.c
|
||||
asec.c
|
||||
asech.c
|
||||
avcs.c
|
||||
aver.c
|
||||
cot.c
|
||||
coth.c
|
||||
crd.c
|
||||
csc.c
|
||||
csch.c
|
||||
cvc.c
|
||||
cvs.c
|
||||
exc.c
|
||||
exs.c
|
||||
hcc.c
|
||||
hcv.c
|
||||
hv.c
|
||||
hvc.c
|
||||
log2i.c
|
||||
log2p.c
|
||||
sec.c
|
||||
sech.c
|
||||
vcs.c
|
||||
ver.c
|
||||
'
|
||||
LIBCPLEXSRCS='
|
||||
cacos.c
|
||||
cacosh.c
|
||||
casin.c
|
||||
casinh.c
|
||||
catan.c
|
||||
catanh.c
|
||||
ccos.c
|
||||
ccosh.c
|
||||
cexp.c
|
||||
clog.c
|
||||
cpow.c
|
||||
csin.c
|
||||
csinh.c
|
||||
csqrt.c
|
||||
ctan.c
|
||||
ctanh.c
|
||||
'
|
||||
LIBCPLEX2SRCS='
|
||||
cacot.c
|
||||
cacoth.c
|
||||
cacsc.c
|
||||
cacsch.c
|
||||
casec.c
|
||||
casech.c
|
||||
casin.c
|
||||
casinh.c
|
||||
catan.c
|
||||
catanh.c
|
||||
ccbrt.c
|
||||
ccos.c
|
||||
ccosh.c
|
||||
ccot.c
|
||||
ccoth.c
|
||||
ccsc.c
|
||||
ccsch.c
|
||||
cexp.c
|
||||
clog.c
|
||||
clog10.c
|
||||
clogb.c
|
||||
cpow.c
|
||||
clog10.c
|
||||
csec.c
|
||||
csech.c
|
||||
csgn.c
|
||||
csin.c
|
||||
csinh.c
|
||||
csqrt.c
|
||||
ctan.c
|
||||
ctanh.c
|
||||
prim.c
|
||||
'
|
||||
LIBC1SRCS='
|
||||
@@ -382,6 +568,18 @@ utils.c
|
||||
vastubs.c
|
||||
'
|
||||
|
||||
if $dlibm; then
|
||||
LIBREALSRCS="${LIBREAL2SRCS}"
|
||||
else
|
||||
LIBREALSRCS="${LIBREALSRCS}${LIBREAL2SRCS}"
|
||||
fi
|
||||
|
||||
if $dlibm; then
|
||||
LIBCPLEXSRCS="${LIBCPLEX2SRCS}"
|
||||
else
|
||||
LIBCPLEXSRCS="${LIBCPLEXSRCS}${LIBCPLEX2SRCS}"
|
||||
fi
|
||||
|
||||
amathc="amathc"
|
||||
amath="amath"
|
||||
amathcplex="amathcplex"
|
||||
@@ -393,10 +591,13 @@ appstatement="statement"
|
||||
appsystem="appsystem"
|
||||
program="src/main"
|
||||
|
||||
ldsysflags="-l${appsystem} -l${appfunction} -l${appstatement} -l${appmain} -l${appfunction} -l${appstatement} -l${appmain} "
|
||||
ldlibflags="-l${amathapp} ${libm}-l${amathcplex} ${libm}-l${amath} -l${amathc} ${gcclib}"
|
||||
|
||||
############################ Main Application ###########################
|
||||
{
|
||||
echo "CXX = ${crosscompile}${cxxcompiler}"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}-I. -I.. -Wall"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}${fPIC} -I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "DEL = rm -f"
|
||||
@@ -428,7 +629,7 @@ echo
|
||||
########################### Functions Library ###########################
|
||||
{
|
||||
echo "CXX = ${crosscompile}${cxxcompiler}"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}-I. -I../.. -Wall"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}${fPIC} -I. -I../.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "DEL = rm -f"
|
||||
@@ -460,7 +661,7 @@ echo
|
||||
########################### Statement Library ###########################
|
||||
{
|
||||
echo "CXX = ${crosscompile}${cxxcompiler}"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}-I. -I../.. -Wall"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}${fPIC} -I. -I../.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "DEL = rm -f"
|
||||
@@ -492,7 +693,7 @@ echo
|
||||
############################ System Library #############################
|
||||
{
|
||||
echo "CXX = ${crosscompile}${cxxcompiler}"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}-I. -I.. -Wall"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}${fPIC} -I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "DEL = rm -f"
|
||||
@@ -528,9 +729,11 @@ echo "CXXFLAGS = ${libop}${options} ${cxxflags}-I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "MKDIR = mkdir -p"
|
||||
echo "RMDIR = rm -Rf"
|
||||
echo "DEL = rm -f"
|
||||
echo "INSTALL = install -m 0644"
|
||||
echo "LDCONFIG = ldconfig"
|
||||
echo "DOXYGEN = doxygen"
|
||||
echo "PREFIX = ${prefix}"
|
||||
echo "INSTDIR = \${DESTDIR}\${PREFIX}/lib/amath"
|
||||
echo "INSTDIRI = \${DESTDIR}\${PREFIX}/include/amath"
|
||||
@@ -552,7 +755,7 @@ for f in ${LIBAPPSRCS}
|
||||
do
|
||||
b=`basename $f .cpp`
|
||||
echo "static/${b}.o: ${f}"
|
||||
echo " \${CXX} \${CXXFLAGS} -c ${f} -o static/${b}.o"
|
||||
echo " \${CXX} \${CXXFLAGS}${fPIC} -c ${f} -o static/${b}.o"
|
||||
echo
|
||||
echo "shared/${b}.o: ${f}"
|
||||
echo " \${CXX} \${CXXFLAGS} -fPIC -c ${f} -o shared/${b}.o"
|
||||
@@ -567,12 +770,16 @@ echo " \${MKDIR} static"
|
||||
echo " \${MKDIR} shared"
|
||||
echo
|
||||
echo "\${solib}: build ${files2}"
|
||||
echo " \${CXX} \${CXXFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}.${version} -o \${solib} ${files2}"
|
||||
echo " \${CXX} \${CXXFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}${soverion} -o \${solib} ${files2}"
|
||||
echo
|
||||
echo "\${alib}: build ${files}"
|
||||
echo " \${AR} rcs static/\${alib} ${files}"
|
||||
echo " \${RANLIB} static/\${alib}"
|
||||
echo
|
||||
echo ".PHONY: doc"
|
||||
echo "doc:"
|
||||
echo " \${DOXYGEN} amatha.dox"
|
||||
echo
|
||||
echo ".PHONY: install"
|
||||
echo "install: \${alib} \${solib}"
|
||||
echo " \${MKDIR} \${INSTDIR}"
|
||||
@@ -582,14 +789,18 @@ echo " \${INSTALL} static/\${alib} \${INSTDIR}/\${alib}"
|
||||
echo " \${INSTALL} \${solib} \${INSTDIR}/\${solib}"
|
||||
echo " \${INSTALL} \${pkgconfig} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${INSTALL} aengine.h \${INSTDIRI}/aengine.h"
|
||||
echo " \${INSTALL} bigint.h \${INSTDIRI}/bigint.h"
|
||||
echo " \${INSTALL} charbuf.h \${INSTDIRI}/charbuf.h"
|
||||
echo " \${INSTALL} cplex.h \${INSTDIRI}/cplex.h"
|
||||
echo " \${INSTALL} integer.h \${INSTDIRI}/integer.h"
|
||||
echo " \${INSTALL} nnumb.h \${INSTDIRI}/nnumb.h"
|
||||
echo " \${INSTALL} ntext.h \${INSTDIRI}/ntext.h"
|
||||
echo " \${INSTALL} ntext.h \${INSTDIRI}/ntextd.h"
|
||||
echo " \${INSTALL} ntext.h \${INSTDIRI}/ntextp.h"
|
||||
echo " \${INSTALL} numb.h \${INSTDIRI}/numb.h"
|
||||
echo " \${INSTALL} real.h \${INSTDIRI}/real.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG} \${INSTDIR}"
|
||||
fi
|
||||
echo
|
||||
echo ".PHONY: uninstall"
|
||||
echo "uninstall:"
|
||||
@@ -604,11 +815,19 @@ echo " \${DEL} \${INSTDIRI}/nnumb.h"
|
||||
echo " \${DEL} \${INSTDIRI}/ntext.h"
|
||||
echo " \${DEL} \${INSTDIRI}/numb.h"
|
||||
echo " \${DEL} \${INSTDIRI}/real.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG}"
|
||||
fi
|
||||
echo
|
||||
echo "clean:"
|
||||
echo " \${DEL} static/\${alib} \${solib} ${files} ${files2}"
|
||||
echo
|
||||
echo "very-clean: clean"
|
||||
echo " \${DEL} doxygen.warn"
|
||||
echo " \${RMDIR} man"
|
||||
echo " \${RMDIR} static"
|
||||
echo " \${RMDIR} shared"
|
||||
echo
|
||||
} > src/lib/Makefile
|
||||
#########################################################################
|
||||
|
||||
@@ -619,14 +838,16 @@ echo "CFLAGS = -std=c9x ${libop}${options} ${cflags}-I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "MKDIR = mkdir -p"
|
||||
echo "RMDIR = rm -Rf"
|
||||
echo "DEL = rm -f"
|
||||
echo "INSTALL = install -m 0644"
|
||||
echo "LDCONFIG = ldconfig"
|
||||
echo "DOXYGEN = doxygen"
|
||||
echo "PREFIX = ${prefix}"
|
||||
echo "INSTDIR = \${DESTDIR}\${PREFIX}/lib/amath"
|
||||
echo "INSTDIRI = \${DESTDIR}\${PREFIX}/include/amath"
|
||||
echo "INSTDIRPC = \${DESTDIR}\${PREFIX}/${pkgconfigdir}"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/share/man/man3"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/${mandir}/man3"
|
||||
echo "alib = lib${amathc}.a"
|
||||
echo "solib = lib${amathc}.so"
|
||||
echo "pkgconfig = amathc.pc"
|
||||
@@ -645,7 +866,7 @@ for f in ${LIBC1SRCS}
|
||||
do
|
||||
b=`basename $f .c`
|
||||
echo "static/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo " \${CC} \${CFLAGS}${fPIC} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo
|
||||
echo "shared/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fPIC -fno-builtin -c ${f} -o shared/${b}.o"
|
||||
@@ -660,12 +881,16 @@ echo " \${MKDIR} static"
|
||||
echo " \${MKDIR} shared"
|
||||
echo
|
||||
echo "\${solib}: build ${libcs}"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}.${version} -o \${solib} ${libcs} -lc"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}${soverion} -o \${solib} ${libcs}"
|
||||
echo
|
||||
echo "\${alib}: build ${libc}"
|
||||
echo " \${AR} rcs static/\${alib} ${libc}"
|
||||
echo " \${RANLIB} static/\${alib}"
|
||||
echo
|
||||
echo ".PHONY: doc"
|
||||
echo "doc:"
|
||||
echo " \${DOXYGEN} amathc.dox"
|
||||
echo
|
||||
echo ".PHONY: install"
|
||||
echo "install: \${alib} \${solib}"
|
||||
echo " \${MKDIR} \${INSTDIR}"
|
||||
@@ -677,7 +902,9 @@ echo " \${INSTALL} \${pkgconfig} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${INSTALL} \${manpage} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${INSTALL} ../amath.h \${INSTDIRI}"
|
||||
echo " \${INSTALL} ../amathc.h \${INSTDIRI}"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG} \${INSTDIR}"
|
||||
fi
|
||||
echo
|
||||
echo ".PHONY: uninstall"
|
||||
echo "uninstall:"
|
||||
@@ -687,13 +914,20 @@ echo " \${DEL} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${DEL} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${DEL} \${INSTDIRI}/amath.h"
|
||||
echo " \${DEL} \${INSTDIRI}/amathc.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG}"
|
||||
fi
|
||||
echo
|
||||
echo "clean:"
|
||||
echo " \${DEL} static/\${alib} \${solib} ${libc} ${libcs}"
|
||||
echo
|
||||
echo "very-clean: clean"
|
||||
echo " \${DEL} doxygen.warn"
|
||||
echo " \${RMDIR} man"
|
||||
echo " \${RMDIR} static"
|
||||
echo " \${RMDIR} shared"
|
||||
echo
|
||||
} > src/clib/Makefile
|
||||
|
||||
#########################################################################
|
||||
|
||||
############################# Real Numbers ##############################
|
||||
@@ -703,14 +937,16 @@ echo "CFLAGS = -std=c9x ${libop}${options} ${cflags}-I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "MKDIR = mkdir -p"
|
||||
echo "RMDIR = rm -Rf"
|
||||
echo "DEL = rm -f"
|
||||
echo "INSTALL = install -m 0644"
|
||||
echo "LDCONFIG = ldconfig"
|
||||
echo "DOXYGEN = doxygen"
|
||||
echo "PREFIX = ${prefix}"
|
||||
echo "INSTDIR = \${DESTDIR}\${PREFIX}/lib/amath"
|
||||
echo "INSTDIRI = \${DESTDIR}\${PREFIX}/include/amath"
|
||||
echo "INSTDIRPC = \${DESTDIR}\${PREFIX}/${pkgconfigdir}"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/share/man/man3"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/${mandir}/man3"
|
||||
echo "alib = lib${amath}.a"
|
||||
echo "solib = lib${amath}.so"
|
||||
echo "pkgconfig = amathr.pc"
|
||||
@@ -729,7 +965,7 @@ for f in ${LIBREALSRCS}
|
||||
do
|
||||
b=`basename $f .c`
|
||||
echo "static/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo " \${CC} \${CFLAGS}${fPIC} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo
|
||||
echo "shared/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fPIC -fno-builtin -c ${f} -o shared/${b}.o"
|
||||
@@ -744,12 +980,16 @@ echo " \${MKDIR} static"
|
||||
echo " \${MKDIR} shared"
|
||||
echo
|
||||
echo "\${solib}: build ${libamaths}"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}.${version} -o \${solib} ${libamaths}"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}${soverion} -o \${solib} ${libamaths}"
|
||||
echo
|
||||
echo "\${alib}: build ${libamath}"
|
||||
echo " \${AR} rcs static/\${alib} ${libamath}"
|
||||
echo " \${RANLIB} static/\${alib}"
|
||||
echo
|
||||
echo ".PHONY: doc"
|
||||
echo "doc:"
|
||||
echo " \${DOXYGEN} amathr.dox"
|
||||
echo
|
||||
echo ".PHONY: install"
|
||||
echo "install: \${alib} \${solib}"
|
||||
echo " \${MKDIR} \${INSTDIR}"
|
||||
@@ -759,8 +999,10 @@ echo " \${INSTALL} static/\${alib} \${INSTDIR}/\${alib}"
|
||||
echo " \${INSTALL} \${solib} \${INSTDIR}/\${solib}"
|
||||
echo " \${INSTALL} \${pkgconfig} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${INSTALL} \${manpage} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${INSTALL} ../math.h \${INSTDIRI}/amathr.h"
|
||||
echo " \${INSTALL} ../mathr.h \${INSTDIRI}/mathr.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG} \${INSTDIR}"
|
||||
fi
|
||||
echo
|
||||
echo ".PHONY: uninstall"
|
||||
echo "uninstall:"
|
||||
@@ -768,12 +1010,20 @@ echo " \${DEL} \${INSTDIR}/\${alib}"
|
||||
echo " \${DEL} \${INSTDIR}/\${solib}"
|
||||
echo " \${DEL} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${DEL} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${DEL} \${INSTDIRI}/amathr.h"
|
||||
echo " \${DEL} \${INSTDIRI}/mathr.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG}"
|
||||
fi
|
||||
echo
|
||||
echo "clean:"
|
||||
echo " \${DEL} static/\${alib} \${solib} ${libamath} ${libamaths}"
|
||||
echo
|
||||
echo "very-clean: clean"
|
||||
echo " \${DEL} doxygen.warn"
|
||||
echo " \${RMDIR} man"
|
||||
echo " \${RMDIR} static"
|
||||
echo " \${RMDIR} shared"
|
||||
echo
|
||||
} > src/real/Makefile
|
||||
#########################################################################
|
||||
|
||||
@@ -784,14 +1034,16 @@ echo "CFLAGS = -std=c9x ${libop}${options} ${cxxflags}-I. -I.. -Wall"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "MKDIR = mkdir -p"
|
||||
echo "RMDIR = rm -Rf"
|
||||
echo "DEL = rm -f"
|
||||
echo "INSTALL = install -m 0644"
|
||||
echo "LDCONFIG = ldconfig"
|
||||
echo "DOXYGEN = doxygen"
|
||||
echo "PREFIX = ${prefix}"
|
||||
echo "INSTDIR = \${DESTDIR}\${PREFIX}/lib/amath"
|
||||
echo "INSTDIRI = \${DESTDIR}\${PREFIX}/include/amath"
|
||||
echo "INSTDIRPC = \${DESTDIR}\${PREFIX}/${pkgconfigdir}"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/share/man/man3"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/${mandir}/man3"
|
||||
echo "alib = lib${amathcplex}.a"
|
||||
echo "solib = lib${amathcplex}.so"
|
||||
echo "pkgconfig = amathi.pc"
|
||||
@@ -810,7 +1062,7 @@ for f in ${LIBCPLEXSRCS}
|
||||
do
|
||||
b=`basename $f .c`
|
||||
echo "static/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo " \${CC} \${CFLAGS}${fPIC} -fno-builtin -c ${f} -o static/${b}.o"
|
||||
echo
|
||||
echo "shared/${b}.o: ${f}"
|
||||
echo " \${CC} \${CFLAGS} -fPIC -fno-builtin -c ${f} -o shared/${b}.o"
|
||||
@@ -825,12 +1077,16 @@ echo " \${MKDIR} static"
|
||||
echo " \${MKDIR} shared"
|
||||
echo
|
||||
echo "\${solib}: build ${libcomplexs}"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}.${version} -o \${solib} ${libcomplexs}"
|
||||
echo " \${CC} \${CFLAGS} -shared ${exestrip} -fPIC -Wl,-soname,\${solib}${soverion} -o \${solib} ${libcomplexs}"
|
||||
echo
|
||||
echo "\${alib}: build ${libcomplex}"
|
||||
echo " \${AR} rcs static/\${alib} ${libcomplex}"
|
||||
echo " \${RANLIB} static/\${alib}"
|
||||
echo
|
||||
echo ".PHONY: doc"
|
||||
echo "doc:"
|
||||
echo " \${DOXYGEN} amathi.dox"
|
||||
echo
|
||||
echo ".PHONY: install"
|
||||
echo "install: \${alib} \${solib}"
|
||||
echo " \${MKDIR} \${INSTDIR}"
|
||||
@@ -840,8 +1096,10 @@ echo " \${INSTALL} static/\${alib} \${INSTDIR}/\${alib}"
|
||||
echo " \${INSTALL} \${solib} \${INSTDIR}/\${solib}"
|
||||
echo " \${INSTALL} \${pkgconfig} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${INSTALL} \${manpage} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${INSTALL} ../complex.h \${INSTDIRI}/amathi.h"
|
||||
echo " \${INSTALL} ../mathi.h \${INSTDIRI}/mathi.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG} \${INSTDIR}"
|
||||
fi
|
||||
echo
|
||||
echo ".PHONY: uninstall"
|
||||
echo "uninstall:"
|
||||
@@ -850,12 +1108,20 @@ echo " \${DEL} \${INSTDIR}/\${solib}"
|
||||
echo " \${DEL} \${INSTDIRPC}/\${pkgconfig}"
|
||||
echo " \${DEL} \${INSTDIRM}/\${manpage}"
|
||||
echo " \${DEL} \${INSTDIRPC}/amathi.pc"
|
||||
echo " \${DEL} \${INSTDIRI}/amathi.h"
|
||||
echo " \${DEL} \${INSTDIRI}/mathi.h"
|
||||
if ${useldconfig}; then
|
||||
echo " \${LDCONFIG}"
|
||||
fi
|
||||
echo
|
||||
echo "clean:"
|
||||
echo " \${DEL} static/\${alib} \${solib} ${libcomplex} ${libcomplexs}"
|
||||
echo
|
||||
echo "very-clean: clean"
|
||||
echo " \${DEL} doxygen.warn"
|
||||
echo " \${RMDIR} man"
|
||||
echo " \${RMDIR} static"
|
||||
echo " \${RMDIR} shared"
|
||||
echo
|
||||
} > src/cplex/Makefile
|
||||
#########################################################################
|
||||
|
||||
@@ -868,7 +1134,7 @@ echo "CFLAGS = ${appop}${options} ${cflags}-Wall -Isrc -Isrc/main"
|
||||
echo "CXXFLAGS = ${appop}${options} ${cxxflags}-Wall -Isrc -Isrc/main"
|
||||
echo "AR = ${crosscompile}ar"
|
||||
echo "RANLIB = ${crosscompile}ranlib"
|
||||
echo "LFLAGS = ${ldflags}-l${appsystem} -l${appfunction} -l${appstatement} -l${appmain} -l${appfunction} -l${appstatement} -l${appmain} -l${amathapp} -l${amathcplex} -l${amath} -l${amathc} ${gcclib}"
|
||||
echo "LFLAGS = ${ldflags}${ldsysflags}${ldlibflags}"
|
||||
echo "LPATH = -Lsrc/lib -Lsrc/clib -Lsrc/real -Lsrc/cplex -Lsrc/main/function -Lsrc/main/statement -Lsrc/main -Lsrc/system"
|
||||
echo "LPATHS = -Lsrc/lib/static -Lsrc/clib/static -Lsrc/real/static -Lsrc/cplex/static -Lsrc/main/function -Lsrc/main/statement -Lsrc/main -Lsrc/system"
|
||||
echo "FLXCAT = build/flexcat/flexcat"
|
||||
@@ -878,15 +1144,14 @@ echo "INSTALLP = install -m 0755"
|
||||
echo "INSTALLM = install -m 0644"
|
||||
echo "PREFIX = ${prefix}"
|
||||
echo "INSTDIRP = \${DESTDIR}\${PREFIX}/bin"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/share/man/man1"
|
||||
echo "INSTDIRM = \${DESTDIR}\${PREFIX}/${mandir}/man1"
|
||||
echo
|
||||
echo "all: shared-app"
|
||||
echo "all: shared-libs static-libs static-app"
|
||||
echo "amath: shared-libs static-libs shared-app"
|
||||
echo "static: static-app"
|
||||
echo "app: ${appmain} ${appfunction} ${appstatement} ${appsystem}"
|
||||
echo "libs: ${amathapp} ${amath} ${amathc} ${amathcplex}"
|
||||
echo
|
||||
echo "amath: static-app"
|
||||
echo "static: static-app"
|
||||
echo
|
||||
echo "${program}.o: ${program}.cpp"
|
||||
echo " \${CXX} \${CXXFLAGS} -c ${program}.cpp -o ${program}.o"
|
||||
echo
|
||||
@@ -907,19 +1172,24 @@ echo " cd src/lib && \${MAKE}"
|
||||
echo
|
||||
echo "${amath}:"
|
||||
echo " cd src/real && \${MAKE}"
|
||||
echo
|
||||
echo
|
||||
echo "${amathc}:"
|
||||
echo " cd src/clib && \${MAKE}"
|
||||
echo
|
||||
echo
|
||||
echo "${amathcplex}:"
|
||||
echo " cd src/cplex && \${MAKE}"
|
||||
echo
|
||||
echo "localize:"
|
||||
echo
|
||||
echo "locale:"
|
||||
echo " cd build/flexcat && \${MAKE}"
|
||||
echo " \${FLXCAT} text/keyword.cd src/localize/kword.h=text/keyword.sd"
|
||||
echo " \${FLXCAT} text/help.cd src/localize/help.h=text/help.sd"
|
||||
echo " \${FLXCAT} text/ident.cd src/localize/ident.h=text/ident.sd"
|
||||
echo " \${FLXCAT} text/text.cd src/localize/text.h=text/text.sd"
|
||||
echo " \${FLXCAT} text/keyword.cd src/loc/kword.h=text/keyword.sd"
|
||||
echo " \${FLXCAT} text/help.cd src/loc/help.h=text/help.sd"
|
||||
echo " \${FLXCAT} text/ident.cd src/loc/ident.h=text/ident.sd"
|
||||
echo " \${FLXCAT} text/text.cd src/loc/text.h=text/text.sd"
|
||||
echo
|
||||
echo "doc:"
|
||||
echo " cd src/clib && \${MAKE} doc"
|
||||
echo " cd src/real && \${MAKE} doc"
|
||||
echo " cd src/cplex && \${MAKE} doc"
|
||||
echo
|
||||
echo "catalogs:"
|
||||
echo " cd build/flexcat && \${MAKE}"
|
||||
@@ -927,24 +1197,23 @@ echo " \${MKDIR} dist/catalog/english"
|
||||
echo " \${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG dist/catalog/english/amath-help.catalog"
|
||||
echo " \${FLXCAT} text/ident.cd catalog/english/amath-ident.ct CATALOG dist/catalog/english/amath-ident.catalog"
|
||||
echo " \${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG dist/catalog/english/amath-text.catalog"
|
||||
echo " \${MKDIR} dist/catalog/dansk"
|
||||
echo " \${FLXCAT} text/help.cd catalog/dansk/amath-help.ct CATALOG dist/catalog/dansk/amath-help.catalog"
|
||||
echo " \${FLXCAT} text/ident.cd catalog/dansk/amath-ident.ct CATALOG dist/catalog/dansk/amath-ident.catalog"
|
||||
echo " \${FLXCAT} text/text.cd catalog/dansk/amath-text.ct CATALOG dist/catalog/dansk/amath-text.catalog"
|
||||
echo " \${FLXCAT} text/keyword.cd catalog/dansk/amath-keyword.ct CATALOG dist/catalog/dansk/amath-keyword.catalog"
|
||||
echo
|
||||
echo "shared-app: app libs ${program}.o"
|
||||
echo " \${CC} \${CFLAGS} ${exestrip} ${program}.o -o amath \${LPATH} \${LFLAGS}"
|
||||
echo "shared-libs:"
|
||||
echo " cd src/lib && \${MAKE} shared"
|
||||
echo " cd src/clib && \${MAKE} shared"
|
||||
echo " cd src/real && \${MAKE} shared"
|
||||
echo " cd src/cplex && \${MAKE} shared"
|
||||
echo
|
||||
echo "static-app: ${program}.o"
|
||||
echo "static-libs:"
|
||||
echo " cd src/lib && \${MAKE} static"
|
||||
echo " cd src/clib && \${MAKE} static"
|
||||
echo " cd src/real && \${MAKE} static"
|
||||
echo " cd src/cplex && \${MAKE} static"
|
||||
echo " cd src/main && \${MAKE} static"
|
||||
echo " cd src/system && \${MAKE} static"
|
||||
echo " cd src/main/function && \${MAKE} static"
|
||||
echo " cd src/main/statement && \${MAKE} static"
|
||||
echo
|
||||
echo "shared-app: app shared-libs ${program}.o"
|
||||
echo " \${CC} \${CFLAGS} ${exestrip} ${program}.o -o amath \${LPATH} \${LFLAGS}"
|
||||
echo
|
||||
echo "static-app: app static-libs ${program}.o"
|
||||
echo " \${CC} \${CFLAGS} ${exestrip} ${program}.o -o amath \${LPATHS} \${LFLAGS}"
|
||||
echo
|
||||
echo ".PHONY: test"
|
||||
@@ -953,7 +1222,7 @@ echo " LD_LIBRARY_PATH=src/clib/:src/lib:src/cplex:scr/real"
|
||||
echo " ./amath test"
|
||||
echo
|
||||
echo ".PHONY: install"
|
||||
echo "install: shared-app"
|
||||
echo "install:"
|
||||
echo " cd src/lib && \${MAKE} install"
|
||||
echo " cd src/clib && \${MAKE} install"
|
||||
echo " cd src/real && \${MAKE} install"
|
||||
@@ -983,6 +1252,13 @@ echo " cd src/main/statement && \${MAKE} clean"
|
||||
echo " cd build/flexcat && \${MAKE} clean"
|
||||
echo " \${DEL} ${program}.o amath"
|
||||
echo
|
||||
echo ".PHONY: very-clean"
|
||||
echo "very-clean: clean"
|
||||
echo " cd src/lib && \${MAKE} very-clean"
|
||||
echo " cd src/clib && \${MAKE} very-clean"
|
||||
echo " cd src/real && \${MAKE} very-clean"
|
||||
echo " cd src/cplex && \${MAKE} very-clean"
|
||||
echo
|
||||
} > Makefile
|
||||
#########################################################################
|
||||
|
||||
|
||||
+39
-87
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,18 @@
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __APPLE__
|
||||
# ifndef APPLE
|
||||
# define APPLE
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
# ifndef WINDOWS
|
||||
# define WINDOWS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(AOS3) || defined(AOS4) || defined(AROS) || defined (MORPHOS)
|
||||
# ifndef AMIGA
|
||||
# define AMIGA
|
||||
@@ -72,30 +84,24 @@
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(AMIGA) || defined(HAIKU) || defined(UNIX)
|
||||
# ifndef ANSICONSOLE
|
||||
# define ANSICONSOLE
|
||||
#if defined(HAIKU) || defined(UNIX) || defined(APPLE)
|
||||
# ifndef TERMIOS
|
||||
# define TERMIOS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef HAIKU
|
||||
# include <stdint.h>
|
||||
# include <unistd.h>
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef UNIX
|
||||
# include <stdint.h>
|
||||
# include <unistd.h>
|
||||
# include <dirent.h>
|
||||
# include <termios.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef _WIN32
|
||||
#if defined(WINDOWS)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef AOS3
|
||||
#if defined(AROS) || defined(MORPHOS) || defined(AOS4)
|
||||
# include <stdint.h>
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(AOS3)
|
||||
# include <sys/types.h>
|
||||
# define IPTR LONG*
|
||||
# define uintptr_t uint32_t
|
||||
@@ -105,17 +111,17 @@ typedef u_int32_t uint32_t;
|
||||
typedef u_int64_t uint64_t;
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(AROS) || defined(MORPHOS) || defined(AOS4)
|
||||
# include <stdint.h>
|
||||
# include <sys/types.h>
|
||||
#if (__cplusplus <= 199711L && !defined(WINDOWS)) || !defined(__cplusplus)
|
||||
#ifndef nullptr
|
||||
#define nullptr 0
|
||||
#endif
|
||||
#elif (__cplusplus <= 199711L) && (defined(__GNUC__) || defined(__GNUG__))
|
||||
#ifndef nullptr
|
||||
#define nullptr 0
|
||||
#endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if (__cplusplus <= 199711L && !defined(_WIN32)) || !defined(__cplusplus)
|
||||
#define nullptr 0
|
||||
#endif
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#define nullptr 0
|
||||
#endif
|
||||
#define assert(x)
|
||||
/******************************************************************************/
|
||||
/* Compilers*/
|
||||
#if defined(__clang__)
|
||||
@@ -208,8 +214,10 @@ typedef u_int64_t uint64_t;
|
||||
#define SPACE " "
|
||||
#define DOT "."
|
||||
/******************************************************************************/
|
||||
#ifdef _WIN32
|
||||
#if defined(WINDOWS)
|
||||
#define NEWLINE "\r\n"
|
||||
#elif defined(APPLE)
|
||||
#define NEWLINE "\r"
|
||||
#else
|
||||
#define NEWLINE "\n"
|
||||
#endif
|
||||
@@ -272,30 +280,15 @@ typedef int bool;
|
||||
# define TXTFPU EMPTYSTRING
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(WITHTEST) && !defined(ANSICONSOLE)
|
||||
# define TXTOPTS "TEST"
|
||||
#endif
|
||||
#if !defined(WITHTEST) && defined(ANSICONSOLE)
|
||||
# define TXTOPTS "ANSI"
|
||||
#endif
|
||||
#if defined(WITHTEST) && defined(ANSICONSOLE)
|
||||
# define TXTOPTS "ANSI, TEST"
|
||||
#endif
|
||||
#ifdef TXTOPTS
|
||||
# define TXTOPTMSG SPACE "(OPT: " TXTOPTS ")"
|
||||
#else
|
||||
# define TXTOPTMSG EMPTYSTRING
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#define TXTARCH TXTCPU TXTFPU
|
||||
#define RELDATESTAMP "(12-03-2017)"
|
||||
#define TXTDOSVERSION "\0$VER: amath 1.70" SPACE RELDATESTAMP SPACE TXTARCH
|
||||
#define TXTTITLE "amath version 1.7.0"
|
||||
#define RELDATESTAMP "(14-07-2017)"
|
||||
#define TXTDOSVERSION "\0$VER: amath 1.82" SPACE RELDATESTAMP SPACE TXTARCH
|
||||
#define TXTTITLE "amath version 1.8.2"
|
||||
#define TXTCOPYRIGHT "(c) 2017 Carsten Sonne Larsen"
|
||||
#define TXTSTARTMSG TXTTITLE SPACE TXTCOPYRIGHT
|
||||
/******************************************************************************/
|
||||
#define TXTVERSMSG TXTTITLE SPACE RELDATESTAMP SPACE TXTARCH
|
||||
#define TXTCOMPMSG "Compiled with " COMP_NAME SPACE COMP_VERS TXTOPTMSG
|
||||
#define TXTCOMPMSG "Compiled with " COMP_NAME SPACE COMP_VERS
|
||||
/******************************************************************************/
|
||||
#define CPROCNAME "amath_console"
|
||||
/******************************************************************************/
|
||||
@@ -318,45 +311,4 @@ typedef int bool;
|
||||
#define CATALOG_DEF OC_BuiltInLanguage, "english"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#if defined(ANSICONSOLE)
|
||||
#define HEADLINE "\x1B[1m"
|
||||
#ifdef UNIX
|
||||
#define SYNTAXHIGHLIGHT "\x1B[3m\x1B[32m"
|
||||
#else
|
||||
#define SYNTAXHIGHLIGHT "\x1B[32m"
|
||||
#endif
|
||||
#define NORMALTEXT "\x1B[0m"
|
||||
#define BOLD "\x1B[1m"
|
||||
#define ITALICS "\x1B[3m"
|
||||
#define UNDERLINE "\x1B[4m"
|
||||
#define COLOR01 "\x1B[31m"
|
||||
#define COLOR02 "\x1B[32m"
|
||||
#define COLOR03 "\x1B[33m"
|
||||
#define CURSORFORWARD "\x1B[1C"
|
||||
#define CURSORBACKWARD "\x1B[1D"
|
||||
#define ERASEINLINE "\x1B[K"
|
||||
#define INSERT1CHAR "\x1B[1@"
|
||||
#define DELETE1CHAR "\x1B[1P"
|
||||
#define DELETELINE "\x0D\x1B[K"
|
||||
#define CLEARWINDOW "\x1B[1;1H\x1B[J"
|
||||
/******************************************************************************/
|
||||
#else
|
||||
#define HEADLINE EMPTYSTRING
|
||||
#define SYNTAXHIGHLIGHT EMPTYSTRING
|
||||
#define NORMALTEXT EMPTYSTRING
|
||||
#define BOLD EMPTYSTRING
|
||||
#define ITALICS EMPTYSTRING
|
||||
#define UNDERLINE EMPTYSTRING
|
||||
#define COLOR01 EMPTYSTRING
|
||||
#define COLOR02 EMPTYSTRING
|
||||
#define COLOR03 EMPTYSTRING
|
||||
#define CURSORFORWARD EMPTYSTRING
|
||||
#define CURSORBACKWARD EMPTYSTRING
|
||||
#define ERASEINLINE EMPTYSTRING
|
||||
#define INSERT1CHAR EMPTYSTRING
|
||||
#define DELETE1CHAR EMPTYSTRING
|
||||
#define DELETELINE EMPTYSTRING
|
||||
#define CLEARWINDOW EMPTYSTRING
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#endif
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amath", "amath.vcxproj", "{834DBB3E-042B-41E5-9400-EEC16CF003C7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Debug|x64.Build.0 = Debug|x64
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Debug|x86.Build.0 = Debug|Win32
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Release|x64.ActiveCfg = Release|x64
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Release|x64.Build.0 = Release|x64
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Release|x86.ActiveCfg = Release|Win32
|
||||
{834DBB3E-042B-41E5-9400-EEC16CF003C7}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,146 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{834DBB3E-042B-41E5-9400-EEC16CF003C7}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>amath</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+3
-4
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
|
||||
/**
|
||||
* @file amathc.h
|
||||
* @brief C functions for manipulating strings and memory.
|
||||
*
|
||||
* @brief C functions for manipulating strings and memory
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -51,9 +50,9 @@ typedef struct
|
||||
|
||||
void* AllocMemSafe(size_t);
|
||||
void FreeMemSafe(void*);
|
||||
void DetachMemSafe(void*);
|
||||
void FreeAllSafe();
|
||||
void MemUsage(long*, long*, long*);
|
||||
|
||||
int StrLen(const char* string);
|
||||
bool StrIsEqual(const char* s1, const char* s2);
|
||||
void MemSet(void* destination, int c0, unsigned int length);
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
CC = gcc
|
||||
CFLAGS = -std=c9x -O3 -DWITHTEST -I. -I.. -Wall
|
||||
AR = ar
|
||||
RANLIB = ranlib
|
||||
MKDIR = mkdir -p
|
||||
DEL = rm -f
|
||||
INSTALL = install -m 0644
|
||||
LDCONFIG = ldconfig
|
||||
PREFIX = /usr
|
||||
INSTDIR = ${DESTDIR}${PREFIX}/lib/amath
|
||||
INSTDIRI = ${DESTDIR}${PREFIX}/include/amath
|
||||
INSTDIRPC = ${DESTDIR}${PREFIX}/lib/pkgconfig
|
||||
INSTDIRM = ${DESTDIR}${PREFIX}/share/man/man3
|
||||
alib = libamathc.a
|
||||
solib = libamathc.so
|
||||
pkgconfig = amathc.pc
|
||||
manpage = amathc.3
|
||||
|
||||
all: static shared
|
||||
|
||||
static: ${alib}
|
||||
|
||||
shared: ${solib}
|
||||
|
||||
static/alloccpy.o: alloccpy.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c alloccpy.c -o static/alloccpy.o
|
||||
|
||||
shared/alloccpy.o: alloccpy.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c alloccpy.c -o shared/alloccpy.o
|
||||
|
||||
static/mem.o: mem.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c mem.c -o static/mem.o
|
||||
|
||||
shared/mem.o: mem.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c mem.c -o shared/mem.o
|
||||
|
||||
static/memcpy.o: memcpy.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c memcpy.c -o static/memcpy.o
|
||||
|
||||
shared/memcpy.o: memcpy.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c memcpy.c -o shared/memcpy.o
|
||||
|
||||
static/memset.o: memset.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c memset.c -o static/memset.o
|
||||
|
||||
shared/memset.o: memset.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c memset.c -o shared/memset.o
|
||||
|
||||
static/strcmp.o: strcmp.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c strcmp.c -o static/strcmp.o
|
||||
|
||||
shared/strcmp.o: strcmp.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c strcmp.c -o shared/strcmp.o
|
||||
|
||||
static/strlen.o: strlen.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c strlen.c -o static/strlen.o
|
||||
|
||||
shared/strlen.o: strlen.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c strlen.c -o shared/strlen.o
|
||||
|
||||
static/untag.o: untag.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c untag.c -o static/untag.o
|
||||
|
||||
shared/untag.o: untag.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c untag.c -o shared/untag.o
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
${MKDIR} static
|
||||
${MKDIR} shared
|
||||
|
||||
${solib}: build shared/alloccpy.o shared/mem.o shared/memcpy.o shared/memset.o shared/strcmp.o shared/strlen.o shared/untag.o
|
||||
${CC} ${CFLAGS} -shared -s -fPIC -Wl,-soname,${solib}.1.7.0 -o ${solib} shared/alloccpy.o shared/mem.o shared/memcpy.o shared/memset.o shared/strcmp.o shared/strlen.o shared/untag.o -lc
|
||||
|
||||
${alib}: build static/alloccpy.o static/mem.o static/memcpy.o static/memset.o static/strcmp.o static/strlen.o static/untag.o
|
||||
${AR} rcs static/${alib} static/alloccpy.o static/mem.o static/memcpy.o static/memset.o static/strcmp.o static/strlen.o static/untag.o
|
||||
${RANLIB} static/${alib}
|
||||
|
||||
.PHONY: install
|
||||
install: ${alib} ${solib}
|
||||
${MKDIR} ${INSTDIR}
|
||||
${MKDIR} ${INSTDIRPC}
|
||||
${MKDIR} ${INSTDIRI}
|
||||
${INSTALL} static/${alib} ${INSTDIR}/${alib}
|
||||
${INSTALL} ${solib} ${INSTDIR}/${solib}
|
||||
${INSTALL} ${pkgconfig} ${INSTDIRPC}/${pkgconfig}
|
||||
${INSTALL} ${manpage} ${INSTDIRM}/${manpage}
|
||||
${INSTALL} ../amath.h ${INSTDIRI}
|
||||
${INSTALL} ../amathc.h ${INSTDIRI}
|
||||
${LDCONFIG} ${INSTDIR}
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
${DEL} ${INSTDIR}/${alib}
|
||||
${DEL} ${INSTDIR}/${solib}
|
||||
${DEL} ${INSTDIRPC}/${pkgconfig}
|
||||
${DEL} ${INSTDIRM}/${manpage}
|
||||
${DEL} ${INSTDIRI}/amath.h
|
||||
${DEL} ${INSTDIRI}/amathc.h
|
||||
${LDCONFIG}
|
||||
|
||||
clean:
|
||||
${DEL} static/${alib} ${solib} static/alloccpy.o static/mem.o static/memcpy.o static/memset.o static/strcmp.o static/strlen.o static/untag.o shared/alloccpy.o shared/mem.o shared/memcpy.o shared/memset.o shared/strcmp.o shared/strlen.o shared/untag.o
|
||||
|
||||
+3
-3
@@ -23,13 +23,13 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "amathc.h"
|
||||
|
||||
#ifdef AMIGA
|
||||
#if defined(AMIGA)
|
||||
#include <clib/exec_protos.h>
|
||||
#endif
|
||||
|
||||
@@ -58,7 +58,7 @@ unsigned int AllocAndCopy(char** destination, const char* source)
|
||||
*destination = AllocMemSafe(size);
|
||||
d = *destination;
|
||||
|
||||
#ifdef AMIGA // Take advantage of exec
|
||||
#if defined(AMIGA) // Take advantage of exec
|
||||
CopyMem(s, d, n);
|
||||
#else
|
||||
while (n--)
|
||||
|
||||
+219
-250
@@ -1,26 +1,39 @@
|
||||
.TH "amath/amathc.h" 3 "Wed Mar 1 2017" "Version 1.7.0" "amath" \" -*- nroff -*-
|
||||
.ad l
|
||||
.nh
|
||||
.\" Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.TH "amathc.h" 3 "Version 1.8.2" "July 14 2017"
|
||||
.SH NAME
|
||||
amathc.h \- C functions for manipulating strings and memory
|
||||
|
||||
.SH SYNOPSIS
|
||||
.br
|
||||
.PP
|
||||
\fC#include <stddef\&.h>\fP
|
||||
.br
|
||||
\fC#include 'amath\&.h'\fP
|
||||
.br
|
||||
|
||||
.SS "Classes"
|
||||
|
||||
\fC#include \fB"amathc\&.h"\fP
|
||||
.SS "Data Structures"
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "struct \fBtexttag\fP"
|
||||
.br
|
||||
.in -1c
|
||||
.SS "Functions"
|
||||
|
||||
.in +1c
|
||||
.ti -1c
|
||||
.RI "void * \fBAllocMemSafe\fP (size_t)"
|
||||
@@ -31,6 +44,10 @@ amathc.h \- C functions for manipulating strings and memory
|
||||
.br
|
||||
.RI "\fIDeallocate memory from the global memory list\&. \fP"
|
||||
.ti -1c
|
||||
.RI "void \fBDetachMemSafe\fP (void *)"
|
||||
.br
|
||||
.RI "\fIDetach an allocated memory from the global memory list\&. \fP"
|
||||
.ti -1c
|
||||
.RI "void \fBFreeAllSafe\fP ()"
|
||||
.br
|
||||
.RI "\fIDeallocate all memory in the global memory list\&. \fP"
|
||||
@@ -43,7 +60,7 @@ amathc.h \- C functions for manipulating strings and memory
|
||||
.br
|
||||
.RI "\fIGet the length of a null terminated string\&. \fP"
|
||||
.ti -1c
|
||||
.RI "\fBbool\fP \fBStrIsEqual\fP (const char *s1, const char *s2)"
|
||||
.RI "bool \fBStrIsEqual\fP (const char *s1, const char *s2)"
|
||||
.br
|
||||
.RI "\fICompare two null terminated strings to each other\&. \fP"
|
||||
.ti -1c
|
||||
@@ -61,21 +78,11 @@ amathc.h \- C functions for manipulating strings and memory
|
||||
.ti -1c
|
||||
.RI "void \fBUntag\fP (char *destination, const char *source, \fBtexttag\fP tags[], unsigned int tagcount)"
|
||||
.br
|
||||
.in -1c
|
||||
.SH "Detailed Description"
|
||||
.PP
|
||||
C functions for manipulating strings and memory\&.
|
||||
|
||||
|
||||
.PP
|
||||
Definition in file \fBamathc\&.h\fP\&.
|
||||
.SH "Function Documentation"
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
.SS "unsigned int AllocAndCopy (char ** destination, const char * source)"
|
||||
.br
|
||||
.PP
|
||||
Allocate memory and copy a string into the array\&.
|
||||
Allocate memory and copy a string into the array\&.
|
||||
.PP
|
||||
Definition at line 40 of file alloccpy\&.c\&.
|
||||
.PP
|
||||
@@ -100,18 +107,13 @@ Definition at line 40 of file alloccpy\&.c\&.
|
||||
58 *destination = AllocMemSafe(size);
|
||||
59 d = *destination;
|
||||
60
|
||||
61 #ifdef AMIGA // Take advantage of exec
|
||||
62 CopyMem(s, d, n);
|
||||
63 #else
|
||||
64 while (n--)
|
||||
65 *d++ = *s++;
|
||||
66 #endif
|
||||
67
|
||||
68 return size;
|
||||
69 }
|
||||
.fi
|
||||
.SS "void* AllocMemSafe (size_t)"
|
||||
|
||||
.PP
|
||||
Allocate memory and add it to the global memory list\&.
|
||||
.PP
|
||||
@@ -122,7 +124,7 @@ Definition at line 86 of file mem\&.c\&.
|
||||
88 struct MemoryBlock* newblock;
|
||||
89 size_t allocsize;
|
||||
90
|
||||
91 if (list == NULL)
|
||||
91 if (list == nullptr)
|
||||
92 {
|
||||
93 list = (struct MemoryList*)ALLOC_MEM(sizeof(struct MemoryList));
|
||||
94 if (!list)
|
||||
@@ -131,7 +133,7 @@ Definition at line 86 of file mem\&.c\&.
|
||||
97 return 0;
|
||||
98 }
|
||||
99
|
||||
100 list->first = NULL;
|
||||
100 list->first = nullptr;
|
||||
101 list->peak = 0;
|
||||
102 list->size = 0;
|
||||
103 list->count = 0;
|
||||
@@ -175,254 +177,211 @@ Definition at line 86 of file mem\&.c\&.
|
||||
141 return newblock->address;
|
||||
142 }
|
||||
.fi
|
||||
.SS "void DetachMemSafe (void * block)"
|
||||
.PP
|
||||
Detach an allocated memory from the global memory list\&. The memory block is only detached, not deallocated\&.
|
||||
.PP
|
||||
Definition at line 209 of file mem\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
210 {
|
||||
211 RemoveMemSafe(block, false);
|
||||
212 }
|
||||
.fi
|
||||
.SS "void FreeAllSafe ()"
|
||||
|
||||
.PP
|
||||
Deallocate all memory in the global memory list\&.
|
||||
.PP
|
||||
Definition at line 199 of file mem\&.c\&.
|
||||
Definition at line 217 of file mem\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
200 {
|
||||
201 struct MemoryBlock *current, *next;
|
||||
202
|
||||
203 if (list == NULL)
|
||||
204 {
|
||||
205 return;
|
||||
206 }
|
||||
207
|
||||
208 current = list->first;
|
||||
209 while (current != NULL)
|
||||
210 {
|
||||
211 next = current->next;
|
||||
212 FREE_MEM(current->address);
|
||||
213 FREE_MEM(current);
|
||||
214 current = next;
|
||||
215 }
|
||||
216
|
||||
217 FREE_MEM(list);
|
||||
218 list = NULL;
|
||||
219 }
|
||||
218 {
|
||||
219 struct MemoryBlock *current, *next;
|
||||
220
|
||||
221 if (list == nullptr)
|
||||
222 {
|
||||
223 return;
|
||||
224 }
|
||||
225
|
||||
226 current = list->first;
|
||||
227 while (current != nullptr)
|
||||
228 {
|
||||
229 next = current->next;
|
||||
230 FREE_MEM(current->address);
|
||||
231 FREE_MEM(current);
|
||||
232 current = next;
|
||||
233 }
|
||||
234
|
||||
235 FREE_MEM(list);
|
||||
236 list = nullptr;
|
||||
237 }
|
||||
.fi
|
||||
.SS "void FreeMemSafe (void *)"
|
||||
|
||||
.PP
|
||||
Deallocate memory from the global memory list\&.
|
||||
.PP
|
||||
Definition at line 147 of file mem\&.c\&.
|
||||
Definition at line 200 of file mem\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
148 {
|
||||
149 struct MemoryBlock *current, *previous;
|
||||
150
|
||||
151 if (list == NULL || block == NULL)
|
||||
152 {
|
||||
153 dealloc_error("list", 0);
|
||||
154 return;
|
||||
155 }
|
||||
156
|
||||
157 if (block == NULL)
|
||||
158 {
|
||||
159 dealloc_error("memory", 0);
|
||||
160 return;
|
||||
161 }
|
||||
162
|
||||
163 previous = NULL;
|
||||
164 current = list->first;
|
||||
165 while (current != NULL && current->address != block)
|
||||
166 {
|
||||
167 previous = current;
|
||||
168 current = current->next;
|
||||
169 }
|
||||
170
|
||||
171 if (current == NULL)
|
||||
172 {
|
||||
173 dealloc_error("address not found", block);
|
||||
174 return;
|
||||
175 }
|
||||
176
|
||||
177 if (previous == NULL)
|
||||
178 {
|
||||
179 list->first = current->next;
|
||||
180 }
|
||||
181 else
|
||||
182 {
|
||||
183 previous->next = current->next;
|
||||
184 }
|
||||
185
|
||||
186 list->size -= current->size;
|
||||
187 list->count--;
|
||||
188
|
||||
189 FREE_MEM(current->address);
|
||||
190 current->address = NULL;
|
||||
191 current->next = NULL;
|
||||
192 current->size = 0;
|
||||
193 FREE_MEM(current);
|
||||
194 }
|
||||
201 {
|
||||
202 RemoveMemSafe(block, true);
|
||||
203 }
|
||||
.fi
|
||||
.SS "void MemCopy (void * destination, const void * source, unsigned int length)"
|
||||
|
||||
.PP
|
||||
Copy a block of memory, handling overlap\&.
|
||||
.PP
|
||||
Definition at line 77 of file memcpy\&.c\&.
|
||||
Definition at line 75 of file memcpy\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
78 {
|
||||
79 char* dst = (char*) destination;
|
||||
80 const char* src = (const char*) source;
|
||||
81 unsigned int t;
|
||||
82
|
||||
83 if (length == 0 || dst == src) // nothing to do
|
||||
84 return;
|
||||
85
|
||||
86 if ((mem_ptr)dst < (mem_ptr)src)
|
||||
87 {
|
||||
88 // Copy forward
|
||||
89 #ifdef AMIGA // Take advantage of exec
|
||||
90 CopyMem((void*)source, destination, length);
|
||||
91 #else
|
||||
92 t = (mem_ptr)src; // only need low bits
|
||||
93 if ((t | (mem_ptr)dst) & wmask)
|
||||
94 {
|
||||
95 // Try to align operands\&. This cannot be done unless the low bits match\&.
|
||||
96 if ((t ^ (mem_ptr)dst) & wmask || length < wsize)
|
||||
97 t = length;
|
||||
98 else
|
||||
99 t = wsize - (t & wmask);
|
||||
100 length -= t;
|
||||
101
|
||||
102 TLOOP1(*dst++ = *src++);
|
||||
103 }
|
||||
104
|
||||
105 // Copy whole words, then mop up any trailing bytes\&.
|
||||
106 t = length / wsize;
|
||||
107 TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
|
||||
108
|
||||
109 t = length & wmask;
|
||||
110 TLOOP(*dst++ = *src++);
|
||||
111 #endif
|
||||
112 }
|
||||
113 else
|
||||
114 {
|
||||
115 // Copy backwards\&. Otherwise essentially the same\&.
|
||||
116 // Alignment works as before, except that it takes
|
||||
117 // (t&wmask) bytes to align, not wsize-(t&wmask)\&.
|
||||
118 src += length;
|
||||
119 dst += length;
|
||||
120 t = (mem_ptr)src;
|
||||
121 if ((t | (mem_ptr)dst) & wmask)
|
||||
122 {
|
||||
123 if ((t ^ (mem_ptr)dst) & wmask || length <= wsize)
|
||||
124 t = length;
|
||||
125 else
|
||||
126 t &= wmask;
|
||||
127 length -= t;
|
||||
128
|
||||
129 TLOOP1(*--dst = *--src);
|
||||
130 }
|
||||
131
|
||||
132 t = length / wsize;
|
||||
133 TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
|
||||
134
|
||||
135 t = length & wmask;
|
||||
136 TLOOP(*--dst = *--src);
|
||||
137 }
|
||||
138 }
|
||||
76 {
|
||||
77 char* dst = (char*) destination;
|
||||
78 const char* src = (const char*) source;
|
||||
79 unsigned int t;
|
||||
80
|
||||
81 if (length == 0 || dst == src) // nothing to do
|
||||
82 return;
|
||||
83
|
||||
84 if ((mem_ptr)dst < (mem_ptr)src)
|
||||
85 {
|
||||
86 // Copy forward
|
||||
90 t = (mem_ptr)src; // only need low bits
|
||||
91 if ((t | (mem_ptr)dst) & wmask)
|
||||
92 {
|
||||
93 // Try to align operands\&. This cannot be done unless the low bits match\&.
|
||||
94 if ((t ^ (mem_ptr)dst) & wmask || length < wsize)
|
||||
95 t = length;
|
||||
96 else
|
||||
97 t = wsize - (t & wmask);
|
||||
98 length -= t;
|
||||
99
|
||||
100 TLOOP1(*dst++ = *src++);
|
||||
101 }
|
||||
102
|
||||
103 // Copy whole words, then mop up any trailing bytes\&.
|
||||
104 t = length / wsize;
|
||||
105 TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
|
||||
106
|
||||
107 t = length & wmask;
|
||||
108 TLOOP(*dst++ = *src++);
|
||||
110 }
|
||||
111 else
|
||||
112 {
|
||||
113 // Copy backwards\&. Otherwise essentially the same\&.
|
||||
114 // Alignment works as before, except that it takes
|
||||
115 // (t&wmask) bytes to align, not wsize-(t&wmask)\&.
|
||||
116 src += length;
|
||||
117 dst += length;
|
||||
118 t = (mem_ptr)src;
|
||||
119 if ((t | (mem_ptr)dst) & wmask)
|
||||
120 {
|
||||
121 if ((t ^ (mem_ptr)dst) & wmask || length <= wsize)
|
||||
122 t = length;
|
||||
123 else
|
||||
124 t &= wmask;
|
||||
125 length -= t;
|
||||
126
|
||||
127 TLOOP1(*--dst = *--src);
|
||||
128 }
|
||||
129
|
||||
130 t = length / wsize;
|
||||
131 TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
|
||||
132
|
||||
133 t = length & wmask;
|
||||
134 TLOOP(*--dst = *--src);
|
||||
135 }
|
||||
136 }
|
||||
.fi
|
||||
.SS "void MemSet (void * destination, int c0, unsigned int length)"
|
||||
|
||||
.PP
|
||||
Fill block of memory with a constant value\&.
|
||||
.PP
|
||||
Definition at line 60 of file memset\&.c\&.
|
||||
Definition at line 56 of file memset\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
61 {
|
||||
62 unsigned char* dst = (unsigned char*) dst0;
|
||||
63 unsigned int t;
|
||||
64 unsigned int c;
|
||||
65
|
||||
66 /*
|
||||
67 * If not enough words, just fill bytes\&. A length >= 2 words
|
||||
68 * guarantees that at least one of them is `complete' after
|
||||
69 * any necessary alignment\&. For instance:
|
||||
70 *
|
||||
71 * |-----------|-----------|-----------|
|
||||
72 * |00|01|02|03|04|05|06|07|08|09|0A|00|
|
||||
73 * ^---------------------^
|
||||
74 * dst dst+length-1
|
||||
75 *
|
||||
76 * but we use a minimum of 3 here since the overhead of the code
|
||||
77 * to do word writes is substantial\&.
|
||||
78 */
|
||||
79 if (length < 3 * wsize)
|
||||
80 {
|
||||
81 while (length != 0)
|
||||
82 {
|
||||
83 *dst++ = c0;
|
||||
84 --length;
|
||||
85 }
|
||||
86 }
|
||||
87
|
||||
88 if ((c = (unsigned char)c0) != 0)
|
||||
89 { /* Fill the word\&. */
|
||||
90 c = (c << 8) | c; /* u_int is 16 bits\&. */
|
||||
91 #if UINT_MAX > 0xffff
|
||||
92 c = (c << 16) | c; /* u_int is 32 bits\&. */
|
||||
93 #endif
|
||||
94 #if UINT_MAX > 0xffffffff
|
||||
95 c = (c << 32) | c; /* u_int is 64 bits\&. */
|
||||
96 #endif
|
||||
97 }
|
||||
98
|
||||
99 /* Align destination by filling in bytes\&. */
|
||||
100 if ((t = (mem_ptr)dst & wmask) != 0)
|
||||
101 {
|
||||
102 t = wsize - t;
|
||||
103 length -= t;
|
||||
104 do
|
||||
105 {
|
||||
106 *dst++ = c0;
|
||||
107 }
|
||||
108 while (--t != 0);
|
||||
109 }
|
||||
110
|
||||
111 /* Fill words\&. Length was >= 2*words so we know t >= 1 here\&. */
|
||||
112 t = length / wsize;
|
||||
113 do
|
||||
114 {
|
||||
115 *(unsigned int*)dst = c;
|
||||
116 dst += wsize;
|
||||
117 }
|
||||
118 while (--t != 0);
|
||||
119
|
||||
120 /* Mop up trailing bytes, if any\&. */
|
||||
121 t = length & wmask;
|
||||
122 if (t != 0)
|
||||
123 do
|
||||
124 {
|
||||
125 *dst++ = c0;
|
||||
126 }
|
||||
127 while (--t != 0);
|
||||
128 }
|
||||
57 {
|
||||
58 unsigned char* dst = (unsigned char*) dst0;
|
||||
59 unsigned int t;
|
||||
60 unsigned int c;
|
||||
61
|
||||
62 /*
|
||||
63 * If not enough words, just fill bytes\&. A length >= 2 words
|
||||
64 * guarantees that at least one of them is `complete' after
|
||||
65 * any necessary alignment\&. For instance:
|
||||
66 *
|
||||
67 * |-----------|-----------|-----------|
|
||||
68 * |00|01|02|03|04|05|06|07|08|09|0A|00|
|
||||
69 * ^---------------------^
|
||||
70 * dst dst+length-1
|
||||
71 *
|
||||
72 * but we use a minimum of 3 here since the overhead of the code
|
||||
73 * to do word writes is substantial\&.
|
||||
74 */
|
||||
75 if (length < 3 * wsize)
|
||||
76 {
|
||||
77 while (length != 0)
|
||||
78 {
|
||||
79 *dst++ = c0;
|
||||
80 --length;
|
||||
81 }
|
||||
82 }
|
||||
83
|
||||
84 if ((c = (unsigned char)c0) != 0)
|
||||
85 { /* Fill the word\&. */
|
||||
86 c = (c << 8) | c; /* u_int is 16 bits\&. */
|
||||
87 #if UINT_MAX > 0xffff
|
||||
88 c = (c << 16) | c; /* u_int is 32 bits\&. */
|
||||
89 #endif
|
||||
90 #if UINT_MAX > 0xffffffff
|
||||
91 c = (c << 32) | c; /* u_int is 64 bits\&. */
|
||||
92 #endif
|
||||
93 }
|
||||
94
|
||||
95 /* Align destination by filling in bytes\&. */
|
||||
96 if ((t = (mem_ptr)dst & wmask) != 0)
|
||||
97 {
|
||||
98 t = wsize - t;
|
||||
99 length -= t;
|
||||
100 do
|
||||
101 {
|
||||
102 *dst++ = c0;
|
||||
103 }
|
||||
104 while (--t != 0);
|
||||
105 }
|
||||
106
|
||||
107 /* Fill words\&. Length was >= 2*words so we know t >= 1 here\&. */
|
||||
108 t = length / wsize;
|
||||
109 do
|
||||
110 {
|
||||
111 *(unsigned int*)dst = c;
|
||||
112 dst += wsize;
|
||||
113 }
|
||||
114 while (--t != 0);
|
||||
115
|
||||
116 /* Mop up trailing bytes, if any\&. */
|
||||
117 t = length & wmask;
|
||||
118 if (t != 0)
|
||||
119 do
|
||||
120 {
|
||||
121 *dst++ = c0;
|
||||
122 }
|
||||
123 while (--t != 0);
|
||||
124 }
|
||||
.fi
|
||||
.SS "void MemUsage (long *, long *, long *)"
|
||||
|
||||
.PP
|
||||
Get memory usage in the global memory list\&.
|
||||
.PP
|
||||
Definition at line 224 of file mem\&.c\&.
|
||||
Definition at line 242 of file mem\&.c\&.
|
||||
.PP
|
||||
.nf
|
||||
225 {
|
||||
226 *blocks = list->count;
|
||||
227 *size = (long)list->size;
|
||||
228 *peak = (long)list->peak;;
|
||||
229 }
|
||||
243 {
|
||||
244 *blocks = list->count;
|
||||
245 *size = (long)list->size;
|
||||
246 *peak = (long)list->peak;;
|
||||
247 }
|
||||
.fi
|
||||
.SS "\fBbool\fP StrIsEqual (const char * s1, const char * s2)"
|
||||
|
||||
.SS "bool StrIsEqual (const char * s1, const char * s2)"
|
||||
.PP
|
||||
Compare two null terminated strings to each other\&.
|
||||
.PP
|
||||
@@ -442,7 +401,6 @@ Definition at line 50 of file strcmp\&.c\&.
|
||||
61 }
|
||||
.fi
|
||||
.SS "int StrLen (const char * string)"
|
||||
|
||||
.PP
|
||||
Get the length of a null terminated string\&.
|
||||
.PP
|
||||
@@ -458,7 +416,6 @@ Definition at line 34 of file strlen\&.c\&.
|
||||
41 }
|
||||
.fi
|
||||
.SS "void Untag (char * destination, const char * source, \fBtexttag\fP tags[], unsigned int tagcount)"
|
||||
|
||||
.PP
|
||||
Definition at line 32 of file untag\&.c\&.
|
||||
.PP
|
||||
@@ -514,6 +471,18 @@ Definition at line 32 of file untag\&.c\&.
|
||||
81 *dest = '\0';
|
||||
82 }
|
||||
.fi
|
||||
.SH "See also"
|
||||
.PP
|
||||
amath(1), amathr(3), amathi(3)
|
||||
.SH HOMEPAGE
|
||||
https://amath.innolan.net/
|
||||
.SH AUTHORS
|
||||
.PP
|
||||
Written by Carsten Sonne Larsen <cs@innolan.net>. The code in MemSet and
|
||||
MemCopy is derived from software contributed to Berkeley by Mike Hibler and
|
||||
Chris Torek.
|
||||
.SH COPYRIGHT
|
||||
Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
.br
|
||||
Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
.br
|
||||
Copyright (c) 1990, 1993 The Regents of the University of California
|
||||
.SH SEE ALSO
|
||||
amath(1), amathr(3), amathi(3)
|
||||
@@ -0,0 +1,154 @@
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "amathc"
|
||||
PROJECT_NUMBER = "1.8.2"
|
||||
PROJECT_BRIEF = "C functions for manipulating strings and memory"
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING = C
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_PACKAGE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = YES
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
CITE_BIB_FILES =
|
||||
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE = doxygen.warn
|
||||
|
||||
INPUT = ../amathc.h .
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
EXCLUDE = amathc.dox
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
USE_MDFILE_AS_MAINPAGE = NO
|
||||
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = NO
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = YES
|
||||
CLANG_OPTIONS =
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
|
||||
GENERATE_MAN = YES
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = UNIX
|
||||
EXPAND_AS_DEFINED = YES
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
||||
GENERATE_HTML = NO
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_RTF = NO
|
||||
GENERATE_XML = NO
|
||||
GENERATE_DOCBOOK = NO
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_PERLMOD = NO
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
EXTERNAL_PAGES = NO
|
||||
CLASS_DIAGRAMS = NO
|
||||
+1
-1
@@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
|
||||
|
||||
Name: amath C library
|
||||
Description: C functions for manipulating strings and memory
|
||||
Version: 1.7.0
|
||||
Version: 1.8.2
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lamathc
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{01757088-637B-45D8-B042-14B76DF11115}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="alloccpy.c" />
|
||||
<ClCompile Include="mem.c" />
|
||||
<ClCompile Include="memcpy.c" />
|
||||
<ClCompile Include="memset.c" />
|
||||
<ClCompile Include="strcmp.c" />
|
||||
<ClCompile Include="strlen.c" />
|
||||
<ClCompile Include="untag.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="untag.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="strlen.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mem.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="alloccpy.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="memcpy.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="memset.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="strcmp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+39
-21
@@ -23,13 +23,13 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "amathc.h"
|
||||
|
||||
#ifdef AMIGA
|
||||
#if defined(AMIGA)
|
||||
#include <stddef.h>
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
@@ -75,7 +75,7 @@ struct MemoryList
|
||||
/**
|
||||
* @brief Global list of allocated memory.
|
||||
*/
|
||||
struct MemoryList* list = NULL;
|
||||
struct MemoryList* list = nullptr;
|
||||
|
||||
void alloc_error(char*, size_t);
|
||||
void dealloc_error(char*, void*);
|
||||
@@ -88,7 +88,7 @@ void* AllocMemSafe(size_t size)
|
||||
struct MemoryBlock* newblock;
|
||||
size_t allocsize;
|
||||
|
||||
if (list == NULL)
|
||||
if (list == nullptr)
|
||||
{
|
||||
list = (struct MemoryList*)ALLOC_MEM(sizeof(struct MemoryList));
|
||||
if (!list)
|
||||
@@ -97,7 +97,7 @@ void* AllocMemSafe(size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
list->first = NULL;
|
||||
list->first = nullptr;
|
||||
list->peak = 0;
|
||||
list->size = 0;
|
||||
list->count = 0;
|
||||
@@ -141,40 +141,37 @@ void* AllocMemSafe(size_t size)
|
||||
return newblock->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deallocate memory from the global memory list.
|
||||
*/
|
||||
void FreeMemSafe(void* block)
|
||||
void RemoveMemSafe(void* block, bool deallocate)
|
||||
{
|
||||
struct MemoryBlock *current, *previous;
|
||||
|
||||
if (list == NULL || block == NULL)
|
||||
if (list == nullptr || block == nullptr)
|
||||
{
|
||||
dealloc_error("list", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (block == NULL)
|
||||
if (block == nullptr)
|
||||
{
|
||||
dealloc_error("memory", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
previous = NULL;
|
||||
previous = nullptr;
|
||||
current = list->first;
|
||||
while (current != NULL && current->address != block)
|
||||
while (current != nullptr && current->address != block)
|
||||
{
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
if (current == NULL)
|
||||
if (current == nullptr)
|
||||
{
|
||||
dealloc_error("address not found", block);
|
||||
return;
|
||||
}
|
||||
|
||||
if (previous == NULL)
|
||||
if (previous == nullptr)
|
||||
{
|
||||
list->first = current->next;
|
||||
}
|
||||
@@ -186,13 +183,34 @@ void FreeMemSafe(void* block)
|
||||
list->size -= current->size;
|
||||
list->count--;
|
||||
|
||||
FREE_MEM(current->address);
|
||||
current->address = NULL;
|
||||
current->next = NULL;
|
||||
if (deallocate)
|
||||
{
|
||||
FREE_MEM(current->address);
|
||||
}
|
||||
|
||||
current->address = nullptr;
|
||||
current->next = nullptr;
|
||||
current->size = 0;
|
||||
FREE_MEM(current);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deallocate memory from the global memory list.
|
||||
*/
|
||||
void FreeMemSafe(void* block)
|
||||
{
|
||||
RemoveMemSafe(block, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detach an allocated memory from the global memory list.
|
||||
* @details The memory block is only detached, not deallocated.
|
||||
*/
|
||||
void DetachMemSafe(void* block)
|
||||
{
|
||||
RemoveMemSafe(block, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deallocate all memory in the global memory list.
|
||||
*/
|
||||
@@ -200,13 +218,13 @@ void FreeAllSafe()
|
||||
{
|
||||
struct MemoryBlock *current, *next;
|
||||
|
||||
if (list == NULL)
|
||||
if (list == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
current = list->first;
|
||||
while (current != NULL)
|
||||
while (current != nullptr)
|
||||
{
|
||||
next = current->next;
|
||||
FREE_MEM(current->address);
|
||||
@@ -215,7 +233,7 @@ void FreeAllSafe()
|
||||
}
|
||||
|
||||
FREE_MEM(list);
|
||||
list = NULL;
|
||||
list = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
#endif
|
||||
|
||||
#ifdef AMIGA
|
||||
#if defined(AMIGA)
|
||||
#include <clib/exec_protos.h>
|
||||
#endif
|
||||
|
||||
@@ -84,7 +84,7 @@ void MemCopy(void* destination, const void* source, unsigned int length)
|
||||
if ((mem_ptr)dst < (mem_ptr)src)
|
||||
{
|
||||
// Copy forward
|
||||
#ifdef AMIGA // Take advantage of exec
|
||||
#if defined(AMIGA) // Take advantage of exec
|
||||
CopyMem((void*)source, destination, length);
|
||||
#else
|
||||
t = (mem_ptr)src; // only need low bits
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
CC = gcc
|
||||
CFLAGS = -std=c9x -O3 -DWITHTEST -I. -I.. -Wall
|
||||
AR = ar
|
||||
RANLIB = ranlib
|
||||
MKDIR = mkdir -p
|
||||
DEL = rm -f
|
||||
INSTALL = install -m 0644
|
||||
LDCONFIG = ldconfig
|
||||
PREFIX = /usr
|
||||
INSTDIR = ${DESTDIR}${PREFIX}/lib/amath
|
||||
INSTDIRI = ${DESTDIR}${PREFIX}/include/amath
|
||||
INSTDIRPC = ${DESTDIR}${PREFIX}/lib/pkgconfig
|
||||
INSTDIRM = ${DESTDIR}${PREFIX}/share/man/man3
|
||||
alib = libamathcplex.a
|
||||
solib = libamathcplex.so
|
||||
pkgconfig = amathi.pc
|
||||
manpage = amathi.3
|
||||
|
||||
all: static shared
|
||||
|
||||
static: ${alib}
|
||||
|
||||
shared: ${solib}
|
||||
|
||||
static/cacos.o: cacos.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacos.c -o static/cacos.o
|
||||
|
||||
shared/cacos.o: cacos.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacos.c -o shared/cacos.o
|
||||
|
||||
static/cacosh.o: cacosh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacosh.c -o static/cacosh.o
|
||||
|
||||
shared/cacosh.o: cacosh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacosh.c -o shared/cacosh.o
|
||||
|
||||
static/cacot.o: cacot.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacot.c -o static/cacot.o
|
||||
|
||||
shared/cacot.o: cacot.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacot.c -o shared/cacot.o
|
||||
|
||||
static/cacoth.o: cacoth.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacoth.c -o static/cacoth.o
|
||||
|
||||
shared/cacoth.o: cacoth.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacoth.c -o shared/cacoth.o
|
||||
|
||||
static/cacsc.o: cacsc.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacsc.c -o static/cacsc.o
|
||||
|
||||
shared/cacsc.o: cacsc.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacsc.c -o shared/cacsc.o
|
||||
|
||||
static/cacsch.o: cacsch.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cacsch.c -o static/cacsch.o
|
||||
|
||||
shared/cacsch.o: cacsch.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cacsch.c -o shared/cacsch.o
|
||||
|
||||
static/casec.o: casec.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c casec.c -o static/casec.o
|
||||
|
||||
shared/casec.o: casec.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c casec.c -o shared/casec.o
|
||||
|
||||
static/casech.o: casech.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c casech.c -o static/casech.o
|
||||
|
||||
shared/casech.o: casech.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c casech.c -o shared/casech.o
|
||||
|
||||
static/casin.o: casin.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c casin.c -o static/casin.o
|
||||
|
||||
shared/casin.o: casin.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c casin.c -o shared/casin.o
|
||||
|
||||
static/casinh.o: casinh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c casinh.c -o static/casinh.o
|
||||
|
||||
shared/casinh.o: casinh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c casinh.c -o shared/casinh.o
|
||||
|
||||
static/catan.o: catan.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c catan.c -o static/catan.o
|
||||
|
||||
shared/catan.o: catan.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c catan.c -o shared/catan.o
|
||||
|
||||
static/catanh.o: catanh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c catanh.c -o static/catanh.o
|
||||
|
||||
shared/catanh.o: catanh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c catanh.c -o shared/catanh.o
|
||||
|
||||
static/ccbrt.o: ccbrt.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccbrt.c -o static/ccbrt.o
|
||||
|
||||
shared/ccbrt.o: ccbrt.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccbrt.c -o shared/ccbrt.o
|
||||
|
||||
static/ccos.o: ccos.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccos.c -o static/ccos.o
|
||||
|
||||
shared/ccos.o: ccos.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccos.c -o shared/ccos.o
|
||||
|
||||
static/ccosh.o: ccosh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccosh.c -o static/ccosh.o
|
||||
|
||||
shared/ccosh.o: ccosh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccosh.c -o shared/ccosh.o
|
||||
|
||||
static/ccot.o: ccot.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccot.c -o static/ccot.o
|
||||
|
||||
shared/ccot.o: ccot.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccot.c -o shared/ccot.o
|
||||
|
||||
static/ccoth.o: ccoth.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccoth.c -o static/ccoth.o
|
||||
|
||||
shared/ccoth.o: ccoth.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccoth.c -o shared/ccoth.o
|
||||
|
||||
static/ccsc.o: ccsc.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccsc.c -o static/ccsc.o
|
||||
|
||||
shared/ccsc.o: ccsc.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccsc.c -o shared/ccsc.o
|
||||
|
||||
static/ccsch.o: ccsch.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ccsch.c -o static/ccsch.o
|
||||
|
||||
shared/ccsch.o: ccsch.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ccsch.c -o shared/ccsch.o
|
||||
|
||||
static/cexp.o: cexp.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cexp.c -o static/cexp.o
|
||||
|
||||
shared/cexp.o: cexp.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cexp.c -o shared/cexp.o
|
||||
|
||||
static/clog.o: clog.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c clog.c -o static/clog.o
|
||||
|
||||
shared/clog.o: clog.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c clog.c -o shared/clog.o
|
||||
|
||||
static/clog10.o: clog10.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c clog10.c -o static/clog10.o
|
||||
|
||||
shared/clog10.o: clog10.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c clog10.c -o shared/clog10.o
|
||||
|
||||
static/clogb.o: clogb.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c clogb.c -o static/clogb.o
|
||||
|
||||
shared/clogb.o: clogb.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c clogb.c -o shared/clogb.o
|
||||
|
||||
static/cpow.o: cpow.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c cpow.c -o static/cpow.o
|
||||
|
||||
shared/cpow.o: cpow.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c cpow.c -o shared/cpow.o
|
||||
|
||||
static/csec.o: csec.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csec.c -o static/csec.o
|
||||
|
||||
shared/csec.o: csec.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csec.c -o shared/csec.o
|
||||
|
||||
static/csech.o: csech.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csech.c -o static/csech.o
|
||||
|
||||
shared/csech.o: csech.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csech.c -o shared/csech.o
|
||||
|
||||
static/csgn.o: csgn.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csgn.c -o static/csgn.o
|
||||
|
||||
shared/csgn.o: csgn.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csgn.c -o shared/csgn.o
|
||||
|
||||
static/csin.o: csin.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csin.c -o static/csin.o
|
||||
|
||||
shared/csin.o: csin.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csin.c -o shared/csin.o
|
||||
|
||||
static/csinh.o: csinh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csinh.c -o static/csinh.o
|
||||
|
||||
shared/csinh.o: csinh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csinh.c -o shared/csinh.o
|
||||
|
||||
static/csqrt.o: csqrt.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c csqrt.c -o static/csqrt.o
|
||||
|
||||
shared/csqrt.o: csqrt.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c csqrt.c -o shared/csqrt.o
|
||||
|
||||
static/ctan.o: ctan.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ctan.c -o static/ctan.o
|
||||
|
||||
shared/ctan.o: ctan.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ctan.c -o shared/ctan.o
|
||||
|
||||
static/ctanh.o: ctanh.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c ctanh.c -o static/ctanh.o
|
||||
|
||||
shared/ctanh.o: ctanh.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c ctanh.c -o shared/ctanh.o
|
||||
|
||||
static/prim.o: prim.c
|
||||
${CC} ${CFLAGS} -fno-builtin -c prim.c -o static/prim.o
|
||||
|
||||
shared/prim.o: prim.c
|
||||
${CC} ${CFLAGS} -fPIC -fno-builtin -c prim.c -o shared/prim.o
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
${MKDIR} static
|
||||
${MKDIR} shared
|
||||
|
||||
${solib}: build shared/cacos.o shared/cacosh.o shared/cacot.o shared/cacoth.o shared/cacsc.o shared/cacsch.o shared/casec.o shared/casech.o shared/casin.o shared/casinh.o shared/catan.o shared/catanh.o shared/ccbrt.o shared/ccos.o shared/ccosh.o shared/ccot.o shared/ccoth.o shared/ccsc.o shared/ccsch.o shared/cexp.o shared/clog.o shared/clog10.o shared/clogb.o shared/cpow.o shared/csec.o shared/csech.o shared/csgn.o shared/csin.o shared/csinh.o shared/csqrt.o shared/ctan.o shared/ctanh.o shared/prim.o
|
||||
${CC} ${CFLAGS} -shared -s -fPIC -Wl,-soname,${solib}.1.7.0 -o ${solib} shared/cacos.o shared/cacosh.o shared/cacot.o shared/cacoth.o shared/cacsc.o shared/cacsch.o shared/casec.o shared/casech.o shared/casin.o shared/casinh.o shared/catan.o shared/catanh.o shared/ccbrt.o shared/ccos.o shared/ccosh.o shared/ccot.o shared/ccoth.o shared/ccsc.o shared/ccsch.o shared/cexp.o shared/clog.o shared/clog10.o shared/clogb.o shared/cpow.o shared/csec.o shared/csech.o shared/csgn.o shared/csin.o shared/csinh.o shared/csqrt.o shared/ctan.o shared/ctanh.o shared/prim.o
|
||||
|
||||
${alib}: build static/cacos.o static/cacosh.o static/cacot.o static/cacoth.o static/cacsc.o static/cacsch.o static/casec.o static/casech.o static/casin.o static/casinh.o static/catan.o static/catanh.o static/ccbrt.o static/ccos.o static/ccosh.o static/ccot.o static/ccoth.o static/ccsc.o static/ccsch.o static/cexp.o static/clog.o static/clog10.o static/clogb.o static/cpow.o static/csec.o static/csech.o static/csgn.o static/csin.o static/csinh.o static/csqrt.o static/ctan.o static/ctanh.o static/prim.o
|
||||
${AR} rcs static/${alib} static/cacos.o static/cacosh.o static/cacot.o static/cacoth.o static/cacsc.o static/cacsch.o static/casec.o static/casech.o static/casin.o static/casinh.o static/catan.o static/catanh.o static/ccbrt.o static/ccos.o static/ccosh.o static/ccot.o static/ccoth.o static/ccsc.o static/ccsch.o static/cexp.o static/clog.o static/clog10.o static/clogb.o static/cpow.o static/csec.o static/csech.o static/csgn.o static/csin.o static/csinh.o static/csqrt.o static/ctan.o static/ctanh.o static/prim.o
|
||||
${RANLIB} static/${alib}
|
||||
|
||||
.PHONY: install
|
||||
install: ${alib} ${solib}
|
||||
${MKDIR} ${INSTDIR}
|
||||
${MKDIR} ${INSTDIRPC}
|
||||
${MKDIR} ${INSTDIRI}
|
||||
${INSTALL} static/${alib} ${INSTDIR}/${alib}
|
||||
${INSTALL} ${solib} ${INSTDIR}/${solib}
|
||||
${INSTALL} ${pkgconfig} ${INSTDIRPC}/${pkgconfig}
|
||||
${INSTALL} ${manpage} ${INSTDIRM}/${manpage}
|
||||
${INSTALL} ../complex.h ${INSTDIRI}/amathi.h
|
||||
${LDCONFIG} ${INSTDIR}
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
${DEL} ${INSTDIR}/${alib}
|
||||
${DEL} ${INSTDIR}/${solib}
|
||||
${DEL} ${INSTDIRPC}/${pkgconfig}
|
||||
${DEL} ${INSTDIRM}/${manpage}
|
||||
${DEL} ${INSTDIRPC}/amathi.pc
|
||||
${DEL} ${INSTDIRI}/amathi.h
|
||||
${LDCONFIG}
|
||||
|
||||
clean:
|
||||
${DEL} static/${alib} ${solib} static/cacos.o static/cacosh.o static/cacot.o static/cacoth.o static/cacsc.o static/cacsch.o static/casec.o static/casech.o static/casin.o static/casinh.o static/catan.o static/catanh.o static/ccbrt.o static/ccos.o static/ccosh.o static/ccot.o static/ccoth.o static/ccsc.o static/ccsch.o static/cexp.o static/clog.o static/clog10.o static/clogb.o static/cpow.o static/csec.o static/csech.o static/csgn.o static/csin.o static/csinh.o static/csqrt.o static/ctan.o static/ctanh.o static/prim.o shared/cacos.o shared/cacosh.o shared/cacot.o shared/cacoth.o shared/cacsc.o shared/cacsch.o shared/casec.o shared/casech.o shared/casin.o shared/casinh.o shared/catan.o shared/catanh.o shared/ccbrt.o shared/ccos.o shared/ccosh.o shared/ccot.o shared/ccoth.o shared/ccsc.o shared/ccsch.o shared/cexp.o shared/clog.o shared/clog10.o shared/clogb.o shared/cpow.o shared/csec.o shared/csech.o shared/csgn.o shared/csin.o shared/csinh.o shared/csqrt.o shared/ctan.o shared/ctanh.o shared/prim.o
|
||||
|
||||
+621
-726
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "amathi"
|
||||
PROJECT_NUMBER = "1.8.2"
|
||||
PROJECT_BRIEF = "Complex numbers math library"
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
EXTENSION_MAPPING = C
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_PACKAGE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = YES
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
CITE_BIB_FILES =
|
||||
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE = doxygen.warn
|
||||
|
||||
INPUT = ../mathi.h .
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
EXCLUDE = amathi.dox
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
USE_MDFILE_AS_MAINPAGE = NO
|
||||
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = NO
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = YES
|
||||
CLANG_OPTIONS =
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
|
||||
GENERATE_MAN = YES
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = UNIX
|
||||
EXPAND_AS_DEFINED = YES
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
||||
GENERATE_HTML = NO
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_RTF = NO
|
||||
GENERATE_XML = NO
|
||||
GENERATE_DOCBOOK = NO
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_PERLMOD = NO
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
EXTERNAL_PAGES = NO
|
||||
CLASS_DIAGRAMS = NO
|
||||
+2
-2
@@ -4,7 +4,7 @@ includedir=${prefix}/include/amath
|
||||
libdir=${exec_prefix}/lib
|
||||
|
||||
Name: amath complex library
|
||||
Description: Functions for handling complex numbers
|
||||
Version: 1.7.0
|
||||
Description: Complex numbers math library
|
||||
Version: 1.8.2
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lamathi
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{278A3E34-C1F0-4176-AA98-6D8CD4F16438}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="cacos.c" />
|
||||
<ClCompile Include="cacosh.c" />
|
||||
<ClCompile Include="cacot.c" />
|
||||
<ClCompile Include="cacoth.c" />
|
||||
<ClCompile Include="cacsc.c" />
|
||||
<ClCompile Include="cacsch.c" />
|
||||
<ClCompile Include="casec.c" />
|
||||
<ClCompile Include="casech.c" />
|
||||
<ClCompile Include="casin.c" />
|
||||
<ClCompile Include="casinh.c" />
|
||||
<ClCompile Include="catan.c" />
|
||||
<ClCompile Include="catanh.c" />
|
||||
<ClCompile Include="ccbrt.c" />
|
||||
<ClCompile Include="ccos.c" />
|
||||
<ClCompile Include="ccosh.c" />
|
||||
<ClCompile Include="ccot.c" />
|
||||
<ClCompile Include="ccoth.c" />
|
||||
<ClCompile Include="ccsc.c" />
|
||||
<ClCompile Include="ccsch.c" />
|
||||
<ClCompile Include="cexp.c" />
|
||||
<ClCompile Include="clog.c" />
|
||||
<ClCompile Include="clog10.c" />
|
||||
<ClCompile Include="clogb.c" />
|
||||
<ClCompile Include="cpow.c" />
|
||||
<ClCompile Include="csec.c" />
|
||||
<ClCompile Include="csech.c" />
|
||||
<ClCompile Include="csgn.c" />
|
||||
<ClCompile Include="csin.c" />
|
||||
<ClCompile Include="csinh.c" />
|
||||
<ClCompile Include="csqrt.c" />
|
||||
<ClCompile Include="ctan.c" />
|
||||
<ClCompile Include="ctanh.c" />
|
||||
<ClCompile Include="prim.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="prim.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="casech.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="casin.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccsc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ctan.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="clog10.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccot.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacos.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccoth.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="catanh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="prim.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cexp.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csinh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccos.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacoth.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacsch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="clogb.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="casec.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csqrt.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csech.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccbrt.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ctanh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="clog.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacsc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cpow.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccosh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacosh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csgn.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="casinh.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csin.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="csec.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="catan.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cacot.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccsch.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="prim.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse cosine of complex number
|
||||
* @version 1.0
|
||||
* @date 14/09/15
|
||||
* @brief Inverse cosine of complex number
|
||||
* @details
|
||||
* Inverse cosine expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cosine of complex number
|
||||
* @version 1.1
|
||||
* @date 15/03/03
|
||||
* @brief Inverse hyperbolic cosine of complex number
|
||||
* @details
|
||||
* Inverse hyperbolic cosine expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse cotangent of complex number
|
||||
* @version 1.1
|
||||
* @date 14/10/01
|
||||
* @brief Inverse cotangent of complex number
|
||||
* @details
|
||||
* Inverse cotangent expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cotangent of complex number
|
||||
* @version 1.0
|
||||
* @date 14/09/15
|
||||
* @brief Inverse hyperbolic cotangent of complex number
|
||||
* @details
|
||||
* Inverse hyperbolic cotangent expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse cosecant of complex number
|
||||
* @version 1.1
|
||||
* @date 14/10/01
|
||||
* @brief Inverse cosecant of complex number
|
||||
* @details
|
||||
* Inverse cosecant expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cosecant of complex number
|
||||
* @version 1.0
|
||||
* @date 14/09/15
|
||||
* @brief Inverse hyperbolic cosecant of complex number
|
||||
* @details
|
||||
* Inverse hyperbolic cosecant expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+1
-5
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse secant expressed using complex logarithms:
|
||||
* @version 1.1
|
||||
* @date 14/10/01
|
||||
* @details
|
||||
* Inverse secant expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-7
@@ -23,23 +23,18 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic secant of complex numbers
|
||||
* @version 1.1
|
||||
* @date 15/03/03
|
||||
* @brief Inverse hyperbolic secant of complex numbers
|
||||
* @details
|
||||
* Inverse hyperbolic secant expressed using complex logarithms:
|
||||
* <pre>
|
||||
* asech(z) = log(sqrt(1 / (z * z) - 1) + 1/z)
|
||||
*
|
||||
* </pre>
|
||||
* More info is available at Wikipedia: <BR>
|
||||
* https://wikipedia.org/wiki/Inverse_hyperbolic_function#Logarithmic_representation
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse sine of complex number
|
||||
* @version 1.1
|
||||
* @date 14/10/01
|
||||
* @brief Inverse sine of complex number
|
||||
* @details
|
||||
* Inverse sine expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+3
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic sine of complex number
|
||||
* @version 1.0
|
||||
* @date 14/09/15
|
||||
* @brief Inverse hyperbolic sine of complex number
|
||||
* @details
|
||||
* Inverse hyperbolic sine expressed using complex logarithms:
|
||||
* <pre>
|
||||
@@ -50,6 +46,7 @@
|
||||
*/
|
||||
complex casinh(complex z)
|
||||
{
|
||||
// TODO: Fix branch cuts
|
||||
complex one = cpack(1.0, 0.0);
|
||||
complex a = cadd(cmul(z, z), one);
|
||||
complex b = cadd(z, csqrt(a));
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse tangent of complex number
|
||||
* @version 1.1
|
||||
* @date 14/10/01
|
||||
* @brief Inverse tangent of complex number
|
||||
* @details
|
||||
* Inverse tangent expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-6
@@ -23,18 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic tangent of complex number
|
||||
* @version 1.0
|
||||
* @date 14/09/15
|
||||
* @brief Inverse hyperbolic tangent of complex number
|
||||
* @details
|
||||
* Inverse hyperbolic tangent expressed using complex logarithms:
|
||||
* <pre>
|
||||
|
||||
+2
-4
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Cube root of complex number
|
||||
* @brief Cube root of complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* cbrt z = exp(1/3 * log(z))
|
||||
|
||||
+2
-6
@@ -27,18 +27,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/ccos.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Cosine of complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Cosine of complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* a+bi
|
||||
|
||||
+2
-6
@@ -30,18 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/ccosh.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic cosine of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Hyperbolic cosine of a complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* a+bi
|
||||
|
||||
+3
-5
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Cotangent of a complex number
|
||||
* @brief Cotangent of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:
|
||||
* <pre>
|
||||
@@ -59,7 +57,7 @@ complex ccot(complex z)
|
||||
|
||||
if (d == 0.0)
|
||||
{
|
||||
w = cpack(D_INFP, D_INFP);
|
||||
w = cpack((double)INFP, (double)INFP);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-4
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic cotangent of a complex number
|
||||
* @brief Hyperbolic cotangent of a complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* acoth(z) = 0.5 * (log(1 + 1/z) - log(1 - 1/z))
|
||||
|
||||
+3
-5
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Cosecant of a complex number
|
||||
* @brief Cosecant of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:
|
||||
* <pre>
|
||||
@@ -59,7 +57,7 @@ complex ccsc(complex z)
|
||||
|
||||
if (d == 0.0)
|
||||
{
|
||||
w = cpack(D_INFP, D_INFP);
|
||||
w = cpack((double)INFP, (double)INFP);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-4
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic secant of a complex number
|
||||
* @brief Hyperbolic secant of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:
|
||||
* <pre>
|
||||
|
||||
+2
-7
@@ -30,19 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cexp.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Returns e to the power of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @details
|
||||
* @brief Returns e to the power of a complex number
|
||||
*/
|
||||
complex cexp(complex z)
|
||||
{
|
||||
|
||||
+2
-7
@@ -30,19 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/clog.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Natural logarithm of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @details
|
||||
* @brief Natural logarithm of a complex number
|
||||
*/
|
||||
complex clog(complex z)
|
||||
{
|
||||
|
||||
+2
-3
@@ -23,15 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Base 10 logarithmic value of complex number.
|
||||
* @brief Base 10 logarithmic value of complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* log z = log(z) / log(10)
|
||||
|
||||
+2
-3
@@ -23,15 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Base 2 logarithmic value of complex number.
|
||||
* @brief Base 2 logarithmic value of complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* lb z = log(z) / log(2)
|
||||
|
||||
+2
-7
@@ -30,19 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/cpow.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Complex number raised to a power
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @details
|
||||
* @brief Complex number raised to a power
|
||||
*/
|
||||
complex cpow(complex a, complex z)
|
||||
{
|
||||
|
||||
+3
-5
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Secant of a complex number
|
||||
* @brief Secant of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:<BR>
|
||||
* https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMSEC_function
|
||||
@@ -59,7 +57,7 @@ complex csec(complex z)
|
||||
|
||||
if (d == 0.0)
|
||||
{
|
||||
w = cpack(D_INFP, D_INFP);
|
||||
w = cpack((double)INFP, (double)INFP);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-4
@@ -23,16 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic secant of a complex number
|
||||
* @brief Hyperbolic secant of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:<BR>
|
||||
* https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMSECH_function
|
||||
|
||||
+2
-3
@@ -23,18 +23,17 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
|
||||
/**
|
||||
* @brief Complex signum
|
||||
* @brief Complex signum
|
||||
* @details
|
||||
* More info is available at Wikipedia: <BR>
|
||||
* https://wikipedia.org/wiki/Sign_function#Complex_signum
|
||||
*
|
||||
*/
|
||||
double csgn(complex z)
|
||||
{
|
||||
|
||||
+2
-6
@@ -30,18 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/csin.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Sine of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Sine of a complex number
|
||||
* @details
|
||||
* Calculated according to description at wikipedia:<BR>
|
||||
* https://wikipedia.org/wiki/Sine#Sine_with_a_complex_argument
|
||||
|
||||
+2
-6
@@ -30,18 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/csinh.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic sine of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Hyperbolic sine of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:<BR>
|
||||
* https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMSINH_function
|
||||
|
||||
+2
-7
@@ -30,19 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/csqrt.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Square root of complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @details
|
||||
* @brief Square root of complex number
|
||||
*/
|
||||
complex csqrt(complex z)
|
||||
{
|
||||
|
||||
+3
-7
@@ -30,18 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/ctan.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Tangent of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Tangent of a complex number
|
||||
* @details
|
||||
* Calculated as in Open Office:<BR>
|
||||
* https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMTAN_function
|
||||
@@ -68,7 +64,7 @@ complex ctan(complex z)
|
||||
|
||||
if (d == 0.0)
|
||||
{
|
||||
w = cpack(D_INFP, D_INFP);
|
||||
w = cpack((double)INFP, (double)INFP);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+2
-6
@@ -30,18 +30,14 @@
|
||||
* http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libm/complex/ctanh.c?rev=1.1
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "prim.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic tangent of a complex number
|
||||
* @version 1.1
|
||||
* @date 2007/08/20
|
||||
* @brief Hyperbolic tangent of a complex number
|
||||
* @details
|
||||
* <pre>
|
||||
* a+bi
|
||||
|
||||
+14
-31
@@ -23,20 +23,17 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "prim.h"
|
||||
#include "complex.h"
|
||||
|
||||
#define REAL_PART(z) ((z).parts[0])
|
||||
#define IMAG_PART(z) ((z).parts[1])
|
||||
|
||||
/**
|
||||
* @brief Real part of complex number.
|
||||
*
|
||||
* @brief Real part of complex number
|
||||
*/
|
||||
double creal(complex z)
|
||||
{
|
||||
@@ -44,8 +41,7 @@ double creal(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Imaginary part of complex number.
|
||||
*
|
||||
* @brief Imaginary part of complex number
|
||||
*/
|
||||
double cimag(complex z)
|
||||
{
|
||||
@@ -53,8 +49,7 @@ double cimag(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Absolute value of complex number.
|
||||
*
|
||||
* @brief Absolute value of complex number
|
||||
*/
|
||||
double cabs(complex z)
|
||||
{
|
||||
@@ -68,8 +63,7 @@ complex conj(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Pack two real numbers into a complex number.
|
||||
*
|
||||
* @brief Pack two real numbers into a complex number
|
||||
*/
|
||||
complex cpack(double x, double y)
|
||||
{
|
||||
@@ -81,8 +75,7 @@ complex cpack(double x, double y)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Truncated value of complex number.
|
||||
*
|
||||
* @brief Truncated value of complex number
|
||||
*/
|
||||
complex ctrunc(complex z)
|
||||
{
|
||||
@@ -92,8 +85,7 @@ complex ctrunc(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Floor value of complex number.
|
||||
*
|
||||
* @brief Floor value of complex number
|
||||
*/
|
||||
complex cfloor(complex z)
|
||||
{
|
||||
@@ -103,8 +95,7 @@ complex cfloor(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Ceiling value of complex number.
|
||||
*
|
||||
* @brief Ceiling value of complex number
|
||||
*/
|
||||
complex cceil(complex z)
|
||||
{
|
||||
@@ -114,8 +105,7 @@ complex cceil(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Division of two complex numbers.
|
||||
*
|
||||
* @brief Division of two complex numbers
|
||||
*/
|
||||
complex cround(complex z)
|
||||
{
|
||||
@@ -125,8 +115,7 @@ complex cround(complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Addition of two complex numbers.
|
||||
*
|
||||
* @brief Addition of two complex numbers
|
||||
*/
|
||||
complex cadd(complex y, complex z)
|
||||
{
|
||||
@@ -136,8 +125,7 @@ complex cadd(complex y, complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Subtraction of two complex numbers.
|
||||
*
|
||||
* @brief Subtraction of two complex numbers
|
||||
*/
|
||||
complex csub(complex y, complex z)
|
||||
{
|
||||
@@ -147,8 +135,7 @@ complex csub(complex y, complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Multiplication of two complex numbers.
|
||||
*
|
||||
* @brief Multiplication of two complex numbers
|
||||
*/
|
||||
complex cmul(complex y, complex z)
|
||||
{
|
||||
@@ -167,8 +154,7 @@ complex cmul(complex y, complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Division of two complex numbers.
|
||||
*
|
||||
* @brief Division of two complex numbers
|
||||
*/
|
||||
complex cdiv(complex y, complex z)
|
||||
{
|
||||
@@ -190,8 +176,7 @@ complex cdiv(complex y, complex z)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reciprocal value of complex number.
|
||||
*
|
||||
* @brief Reciprocal value of complex number
|
||||
*/
|
||||
complex creci(complex z)
|
||||
{
|
||||
@@ -208,7 +193,6 @@ complex creci(complex z)
|
||||
|
||||
/**
|
||||
* @brief Calculate cosh and sinh
|
||||
*
|
||||
*/
|
||||
void cchsh(double x, double* c, double* s)
|
||||
{
|
||||
@@ -231,7 +215,6 @@ void cchsh(double x, double* c, double* s)
|
||||
|
||||
/**
|
||||
* @brief Calculate cosh and cos
|
||||
*
|
||||
*/
|
||||
void cchc(double x, double* ch, double* c)
|
||||
{
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
#include "../mathr.h"
|
||||
#include "../mathi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3 -DWITHTEST -I. -I.. -Wall
|
||||
AR = ar
|
||||
RANLIB = ranlib
|
||||
MKDIR = mkdir -p
|
||||
DEL = rm -f
|
||||
INSTALL = install -m 0644
|
||||
LDCONFIG = ldconfig
|
||||
PREFIX = /usr
|
||||
INSTDIR = ${DESTDIR}${PREFIX}/lib/amath
|
||||
INSTDIRI = ${DESTDIR}${PREFIX}/include/amath
|
||||
INSTDIRPC = ${DESTDIR}${PREFIX}/lib/pkgconfig
|
||||
alib = libamathapp.a
|
||||
solib = libamathapp.so
|
||||
pkgconfig = amatha.pc
|
||||
|
||||
all: static shared
|
||||
|
||||
static: ${alib}
|
||||
|
||||
shared: ${solib}
|
||||
|
||||
static/aengine.o: aengine.cpp
|
||||
${CXX} ${CXXFLAGS} -c aengine.cpp -o static/aengine.o
|
||||
|
||||
shared/aengine.o: aengine.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c aengine.cpp -o shared/aengine.o
|
||||
|
||||
static/charbuf.o: charbuf.cpp
|
||||
${CXX} ${CXXFLAGS} -c charbuf.cpp -o static/charbuf.o
|
||||
|
||||
shared/charbuf.o: charbuf.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c charbuf.cpp -o shared/charbuf.o
|
||||
|
||||
static/integer.o: integer.cpp
|
||||
${CXX} ${CXXFLAGS} -c integer.cpp -o static/integer.o
|
||||
|
||||
shared/integer.o: integer.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c integer.cpp -o shared/integer.o
|
||||
|
||||
static/cplex.o: cplex.cpp
|
||||
${CXX} ${CXXFLAGS} -c cplex.cpp -o static/cplex.o
|
||||
|
||||
shared/cplex.o: cplex.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c cplex.cpp -o shared/cplex.o
|
||||
|
||||
static/nnumb.o: nnumb.cpp
|
||||
${CXX} ${CXXFLAGS} -c nnumb.cpp -o static/nnumb.o
|
||||
|
||||
shared/nnumb.o: nnumb.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c nnumb.cpp -o shared/nnumb.o
|
||||
|
||||
static/ntext.o: ntext.cpp
|
||||
${CXX} ${CXXFLAGS} -c ntext.cpp -o static/ntext.o
|
||||
|
||||
shared/ntext.o: ntext.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c ntext.cpp -o shared/ntext.o
|
||||
|
||||
static/real.o: real.cpp
|
||||
${CXX} ${CXXFLAGS} -c real.cpp -o static/real.o
|
||||
|
||||
shared/real.o: real.cpp
|
||||
${CXX} ${CXXFLAGS} -fPIC -c real.cpp -o shared/real.o
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
${MKDIR} static
|
||||
${MKDIR} shared
|
||||
|
||||
${solib}: build shared/aengine.o shared/charbuf.o shared/integer.o shared/cplex.o shared/nnumb.o shared/ntext.o shared/real.o
|
||||
${CXX} ${CXXFLAGS} -shared -s -fPIC -Wl,-soname,${solib}.1.7.0 -o ${solib} shared/aengine.o shared/charbuf.o shared/integer.o shared/cplex.o shared/nnumb.o shared/ntext.o shared/real.o
|
||||
|
||||
${alib}: build static/aengine.o static/charbuf.o static/integer.o static/cplex.o static/nnumb.o static/ntext.o static/real.o
|
||||
${AR} rcs static/${alib} static/aengine.o static/charbuf.o static/integer.o static/cplex.o static/nnumb.o static/ntext.o static/real.o
|
||||
${RANLIB} static/${alib}
|
||||
|
||||
.PHONY: install
|
||||
install: ${alib} ${solib}
|
||||
${MKDIR} ${INSTDIR}
|
||||
${MKDIR} ${INSTDIRPC}
|
||||
${MKDIR} ${INSTDIRI}
|
||||
${INSTALL} static/${alib} ${INSTDIR}/${alib}
|
||||
${INSTALL} ${solib} ${INSTDIR}/${solib}
|
||||
${INSTALL} ${pkgconfig} ${INSTDIRPC}/${pkgconfig}
|
||||
${INSTALL} aengine.h ${INSTDIRI}/aengine.h
|
||||
${INSTALL} charbuf.h ${INSTDIRI}/charbuf.h
|
||||
${INSTALL} cplex.h ${INSTDIRI}/cplex.h
|
||||
${INSTALL} integer.h ${INSTDIRI}/integer.h
|
||||
${INSTALL} nnumb.h ${INSTDIRI}/nnumb.h
|
||||
${INSTALL} ntext.h ${INSTDIRI}/ntext.h
|
||||
${INSTALL} numb.h ${INSTDIRI}/numb.h
|
||||
${INSTALL} real.h ${INSTDIRI}/real.h
|
||||
${LDCONFIG} ${INSTDIR}
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
${DEL} ${INSTDIR}/${alib}
|
||||
${DEL} ${INSTDIR}/${solib}
|
||||
${DEL} ${INSTDIRPC}/${pkgconfig}
|
||||
${DEL} ${INSTDIRI}/aengine.h
|
||||
${DEL} ${INSTDIRI}/charbuf.h
|
||||
${DEL} ${INSTDIRI}/cplex.h
|
||||
${DEL} ${INSTDIRI}/integer.h
|
||||
${DEL} ${INSTDIRI}/nnumb.h
|
||||
${DEL} ${INSTDIRI}/ntext.h
|
||||
${DEL} ${INSTDIRI}/numb.h
|
||||
${DEL} ${INSTDIRI}/real.h
|
||||
${LDCONFIG}
|
||||
|
||||
clean:
|
||||
${DEL} static/${alib} ${solib} static/aengine.o static/charbuf.o static/integer.o static/cplex.o static/nnumb.o static/ntext.o static/real.o shared/aengine.o shared/charbuf.o shared/integer.o shared/cplex.o shared/nnumb.o shared/ntext.o shared/real.o
|
||||
|
||||
+40
-23
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,14 @@
|
||||
#include "charval.h"
|
||||
#include "aengine.h"
|
||||
|
||||
#define CURSORFORWARD "\x1B[1C"
|
||||
#define CURSORBACKWARD "\x1B[1D"
|
||||
#define ERASEINLINE "\x1B[K"
|
||||
#define INSERT1CHAR "\x1B[1@"
|
||||
#define DELETE1CHAR "\x1B[1P"
|
||||
#define DELETELINE "\x0D\x1B[K"
|
||||
#define DELETE1CHARASC "\b \b"
|
||||
|
||||
AnsiConoleEngine::AnsiConoleEngine(const char* prompt, CharValidator* validator)
|
||||
{
|
||||
this->validator = validator;
|
||||
@@ -49,6 +57,7 @@ AnsiConoleEngine::AnsiConoleEngine(const char* prompt, CharValidator* validator)
|
||||
|
||||
editline = nullptr;
|
||||
curline = -1;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
AnsiConoleEngine::~AnsiConoleEngine()
|
||||
@@ -67,6 +76,16 @@ AnsiConoleEngine::~AnsiConoleEngine()
|
||||
delete prompt;
|
||||
}
|
||||
|
||||
void AnsiConoleEngine::Enable()
|
||||
{
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
void AnsiConoleEngine::Disable()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
void AnsiConoleEngine::StartInput()
|
||||
{
|
||||
linebuf->ClearAndAlloc(lineSize + 1);
|
||||
@@ -82,31 +101,15 @@ void AnsiConoleEngine::StartInput()
|
||||
linedone = false;
|
||||
}
|
||||
|
||||
//#include <real.h>
|
||||
//#include <numb.h>
|
||||
//#include <ntext.h>
|
||||
|
||||
const char* AnsiConoleEngine::ProcessChar(const unsigned char character)
|
||||
{
|
||||
unsigned char ch = character;
|
||||
out->Empty();
|
||||
|
||||
/*
|
||||
// -------------- DEUG ------------------
|
||||
Number *d = new RealNumber((int)ch);
|
||||
NumeralSystem *ns = new DecimalSystem(0);
|
||||
const char *dtext = ns->GetText(d);
|
||||
StrCopy(out->buf, dtext);
|
||||
StrConcat(out->buf, SPACE);
|
||||
delete ns;
|
||||
delete d;
|
||||
return out->buf;
|
||||
// -------------- DEUG ------------------
|
||||
*/
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
// TODO: double buffer
|
||||
out->EnsureGrowth(lineSize);
|
||||
len = lineSize;
|
||||
}
|
||||
|
||||
bool processed = false;
|
||||
@@ -120,7 +123,7 @@ const char* AnsiConoleEngine::ProcessChar(const unsigned char character)
|
||||
escmode = true;
|
||||
processed = true;
|
||||
}
|
||||
else if (ch == 155 || (escmode && ch == 91))
|
||||
else if (ch == 155 || (escmode && ch == 79) || (escmode && ch == 91))
|
||||
{
|
||||
csimode = true;
|
||||
processed = true;
|
||||
@@ -181,7 +184,14 @@ const char* AnsiConoleEngine::ProcessChar(const unsigned char character)
|
||||
while (i != endpos);
|
||||
|
||||
len++;
|
||||
out->Append(DELETE1CHAR);
|
||||
if (enabled)
|
||||
{
|
||||
out->Append(DELETE1CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
out->Append(DELETE1CHARASC);
|
||||
}
|
||||
endpos--;
|
||||
linebuf->ptr = endpos;
|
||||
}
|
||||
@@ -217,8 +227,15 @@ const char* AnsiConoleEngine::ProcessChar(const unsigned char character)
|
||||
}
|
||||
|
||||
len++;
|
||||
out->Append(CURSORBACKWARD);
|
||||
out->Append(DELETE1CHAR);
|
||||
if (enabled)
|
||||
{
|
||||
out->Append(CURSORBACKWARD);
|
||||
out->Append(DELETE1CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
out->Append(DELETE1CHARASC);
|
||||
}
|
||||
cursor--;
|
||||
endpos--;
|
||||
linebuf->ptr = endpos;
|
||||
|
||||
+8
-6
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,17 +32,16 @@
|
||||
|
||||
/**
|
||||
* @file aengine.h
|
||||
* @brief ANSI Console Engine.
|
||||
*
|
||||
* @brief ANSI Console Engine
|
||||
*/
|
||||
|
||||
class CharBuffer;
|
||||
class CharValidator;
|
||||
|
||||
/**
|
||||
* @brief ANSI console controller.
|
||||
* @brief ANSI console controller
|
||||
* @details
|
||||
* More info on the ANSI console is available at [Wikipedia]:
|
||||
* More info on the ANSI console is available at Wikipedia:
|
||||
* https://wikipedia.org/wiki/ANSI_escape_code
|
||||
*/
|
||||
class AnsiConoleEngine
|
||||
@@ -56,6 +55,8 @@ public:
|
||||
const char* GetLine() const;
|
||||
void SetPrompt(const char* string);
|
||||
const char* ProcessChar(const unsigned char character);
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
||||
private:
|
||||
void CopyLine();
|
||||
@@ -63,8 +64,9 @@ private:
|
||||
void ShowNext();
|
||||
|
||||
char* prompt;
|
||||
bool enabled;
|
||||
|
||||
static const int maxLines = 20;
|
||||
static const int maxLines = 100;
|
||||
static const int lineSize = 1024;
|
||||
char** lines;
|
||||
CharBuffer* linebuf;
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
|
||||
|
||||
Name: amath application library
|
||||
Description: C++ library for handling numbers
|
||||
Version: 1.7.0
|
||||
Version: 1.8.2
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -lamathapp -lamathr -lamathi -lamathc
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{B2BC043B-5799-4D01-96B0-C7871F7734FB}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="aengine.cpp" />
|
||||
<ClCompile Include="charbuf.cpp" />
|
||||
<ClCompile Include="cplex.cpp" />
|
||||
<ClCompile Include="integer.cpp" />
|
||||
<ClCompile Include="nnumb.cpp" />
|
||||
<ClCompile Include="ntext.cpp" />
|
||||
<ClCompile Include="real.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="aengine.h" />
|
||||
<ClInclude Include="charbuf.h" />
|
||||
<ClInclude Include="charval.h" />
|
||||
<ClInclude Include="cplex.h" />
|
||||
<ClInclude Include="integer.h" />
|
||||
<ClInclude Include="nnumb.h" />
|
||||
<ClInclude Include="ntext.h" />
|
||||
<ClInclude Include="numb.h" />
|
||||
<ClInclude Include="real.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="charbuf.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="real.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cplex.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ntext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nnumb.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="aengine.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="integer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="charbuf.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ntext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nnumb.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cplex.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="real.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="aengine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="integer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="numb.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="charval.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,999 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 Ryan Juckett
|
||||
* http://www.ryanjuckett.com/
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not
|
||||
* be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
|
||||
#include "bigint.h"
|
||||
#include "mathr.h"
|
||||
|
||||
static int32_t BigInt_Compare(const BigInt &lhs, const BigInt &rhs)
|
||||
{
|
||||
// A bigger length implies a bigger number.
|
||||
int32_t lengthDiff = lhs.m_length - rhs.m_length;
|
||||
if (lengthDiff != 0)
|
||||
return lengthDiff;
|
||||
|
||||
// Compare blocks one by one from high to low.
|
||||
for (int32_t i = lhs.m_length - 1; i >= 0; --i)
|
||||
{
|
||||
if (lhs.m_blocks[i] == rhs.m_blocks[i])
|
||||
continue;
|
||||
else if (lhs.m_blocks[i] > rhs.m_blocks[i])
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// no blocks differed
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void BigInt_Add(BigInt *pResult, const BigInt &lhs, const BigInt &rhs)
|
||||
{
|
||||
// determine which operand has the smaller length
|
||||
const BigInt *pLarge;
|
||||
const BigInt *pSmall;
|
||||
if (lhs.m_length < rhs.m_length)
|
||||
{
|
||||
pSmall = &lhs;
|
||||
pLarge = &rhs;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSmall = &rhs;
|
||||
pLarge = &lhs;
|
||||
}
|
||||
|
||||
const uint32_t largeLen = pLarge->m_length;
|
||||
const uint32_t smallLen = pSmall->m_length;
|
||||
|
||||
// The output will be at least as long as the largest input
|
||||
pResult->m_length = largeLen;
|
||||
|
||||
// Add each block and add carry the overflow to the next block
|
||||
uint64_t carry = 0;
|
||||
const uint32_t *pLargeCur = pLarge->m_blocks;
|
||||
const uint32_t *pLargeEnd = pLargeCur + largeLen;
|
||||
const uint32_t *pSmallCur = pSmall->m_blocks;
|
||||
const uint32_t *pSmallEnd = pSmallCur + smallLen;
|
||||
uint32_t *pResultCur = pResult->m_blocks;
|
||||
while (pSmallCur != pSmallEnd)
|
||||
{
|
||||
uint64_t sum = carry + (uint64_t)(*pLargeCur) + (uint64_t)(*pSmallCur);
|
||||
carry = sum >> 32;
|
||||
(*pResultCur) = sum & 0xFFFFFFFF;
|
||||
++pLargeCur;
|
||||
++pSmallCur;
|
||||
++pResultCur;
|
||||
}
|
||||
|
||||
// Add the carry to any blocks that only exist in the large operand
|
||||
while (pLargeCur != pLargeEnd)
|
||||
{
|
||||
uint64_t sum = carry + (uint64_t)(*pLargeCur);
|
||||
carry = sum >> 32;
|
||||
(*pResultCur) = sum & 0xFFFFFFFF;
|
||||
++pLargeCur;
|
||||
++pResultCur;
|
||||
}
|
||||
|
||||
// If there's still a carry, append a new block
|
||||
if (carry != 0)
|
||||
{
|
||||
assert(carry == 1);
|
||||
assert((uint32_t)(pResultCur - pResult->m_blocks) == largeLen && (largeLen < c_BigInt_MaxBlocks));
|
||||
*pResultCur = 1;
|
||||
pResult->m_length = largeLen + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pResult->m_length = largeLen;
|
||||
}
|
||||
}
|
||||
|
||||
static void BigInt_Multiply(BigInt *pResult, const BigInt &lhs, const BigInt &rhs)
|
||||
{
|
||||
assert(pResult != &lhs && pResult != &rhs);
|
||||
|
||||
// determine which operand has the smaller length
|
||||
const BigInt *pLarge;
|
||||
const BigInt *pSmall;
|
||||
if (lhs.m_length < rhs.m_length)
|
||||
{
|
||||
pSmall = &lhs;
|
||||
pLarge = &rhs;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSmall = &rhs;
|
||||
pLarge = &lhs;
|
||||
}
|
||||
|
||||
// set the maximum possible result length
|
||||
uint32_t maxResultLen = pLarge->m_length + pSmall->m_length;
|
||||
assert(maxResultLen <= c_BigInt_MaxBlocks);
|
||||
|
||||
// clear the result data
|
||||
for (uint32_t *pCur = pResult->m_blocks, *pEnd = pCur + maxResultLen; pCur != pEnd; ++pCur)
|
||||
*pCur = 0;
|
||||
|
||||
// perform standard long multiplication
|
||||
const uint32_t *pLargeBeg = pLarge->m_blocks;
|
||||
const uint32_t *pLargeEnd = pLargeBeg + pLarge->m_length;
|
||||
|
||||
// for each small block
|
||||
uint32_t *pResultStart = pResult->m_blocks;
|
||||
for (const uint32_t *pSmallCur = pSmall->m_blocks, *pSmallEnd = pSmallCur + pSmall->m_length;
|
||||
pSmallCur != pSmallEnd;
|
||||
++pSmallCur, ++pResultStart)
|
||||
{
|
||||
// if non-zero, multiply against all the large blocks and add into the result
|
||||
const uint32_t multiplier = *pSmallCur;
|
||||
if (multiplier != 0)
|
||||
{
|
||||
const uint32_t *pLargeCur = pLargeBeg;
|
||||
uint32_t *pResultCur = pResultStart;
|
||||
uint64_t carry = 0;
|
||||
do
|
||||
{
|
||||
uint64_t product = (*pResultCur) + (*pLargeCur) * (uint64_t)multiplier + carry;
|
||||
carry = product >> 32;
|
||||
*pResultCur = product & 0xFFFFFFFF;
|
||||
++pLargeCur;
|
||||
++pResultCur;
|
||||
} while (pLargeCur != pLargeEnd);
|
||||
|
||||
assert(pResultCur < pResult->m_blocks + maxResultLen);
|
||||
*pResultCur = (uint32_t)(carry & 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
// check if the terminating block has no set bits
|
||||
if (maxResultLen > 0 && pResult->m_blocks[maxResultLen - 1] == 0)
|
||||
pResult->m_length = maxResultLen - 1;
|
||||
else
|
||||
pResult->m_length = maxResultLen;
|
||||
}
|
||||
|
||||
static void BigInt_Multiply(BigInt *pResult, const BigInt &lhs, uint32_t rhs)
|
||||
{
|
||||
// perform long multiplication
|
||||
uint32_t carry = 0;
|
||||
uint32_t *pResultCur = pResult->m_blocks;
|
||||
const uint32_t *pLhsCur = lhs.m_blocks;
|
||||
const uint32_t *pLhsEnd = lhs.m_blocks + lhs.m_length;
|
||||
for (; pLhsCur != pLhsEnd; ++pLhsCur, ++pResultCur)
|
||||
{
|
||||
uint64_t product = (uint64_t)(*pLhsCur) * rhs + carry;
|
||||
*pResultCur = (uint32_t)(product & 0xFFFFFFFF);
|
||||
carry = product >> 32;
|
||||
}
|
||||
|
||||
// if there is a remaining carry, grow the array
|
||||
if (carry != 0)
|
||||
{
|
||||
// grow the array
|
||||
assert(lhs.m_length + 1 <= c_BigInt_MaxBlocks);
|
||||
*pResultCur = (uint32_t)carry;
|
||||
pResult->m_length = lhs.m_length + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pResult->m_length = lhs.m_length;
|
||||
}
|
||||
}
|
||||
|
||||
static void BigInt_Multiply2(BigInt *pResult, const BigInt &in)
|
||||
{
|
||||
// shift all the blocks by one
|
||||
uint32_t carry = 0;
|
||||
|
||||
uint32_t *pResultCur = pResult->m_blocks;
|
||||
const uint32_t *pLhsCur = in.m_blocks;
|
||||
const uint32_t *pLhsEnd = in.m_blocks + in.m_length;
|
||||
for (; pLhsCur != pLhsEnd; ++pLhsCur, ++pResultCur)
|
||||
{
|
||||
uint32_t cur = *pLhsCur;
|
||||
*pResultCur = (cur << 1) | carry;
|
||||
carry = cur >> 31;
|
||||
}
|
||||
|
||||
if (carry != 0)
|
||||
{
|
||||
// grow the array
|
||||
assert(in.m_length + 1 <= c_BigInt_MaxBlocks);
|
||||
*pResultCur = carry;
|
||||
pResult->m_length = in.m_length + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pResult->m_length = in.m_length;
|
||||
}
|
||||
}
|
||||
|
||||
static void BigInt_Multiply2(BigInt *pResult)
|
||||
{
|
||||
// shift all the blocks by one
|
||||
uint32_t carry = 0;
|
||||
|
||||
uint32_t *pCur = pResult->m_blocks;
|
||||
uint32_t *pEnd = pResult->m_blocks + pResult->m_length;
|
||||
for (; pCur != pEnd; ++pCur)
|
||||
{
|
||||
uint32_t cur = *pCur;
|
||||
*pCur = (cur << 1) | carry;
|
||||
carry = cur >> 31;
|
||||
}
|
||||
|
||||
if (carry != 0)
|
||||
{
|
||||
// grow the array
|
||||
assert(pResult->m_length + 1 <= c_BigInt_MaxBlocks);
|
||||
*pCur = carry;
|
||||
++pResult->m_length;
|
||||
}
|
||||
}
|
||||
|
||||
static void BigInt_Multiply10(BigInt *pResult)
|
||||
{
|
||||
// multiply all the blocks
|
||||
uint64_t carry = 0;
|
||||
|
||||
uint32_t *pCur = pResult->m_blocks;
|
||||
uint32_t *pEnd = pResult->m_blocks + pResult->m_length;
|
||||
for (; pCur != pEnd; ++pCur)
|
||||
{
|
||||
uint64_t product = (uint64_t)(*pCur) * 10ull + carry;
|
||||
(*pCur) = (uint32_t)(product & 0xFFFFFFFF);
|
||||
carry = product >> 32;
|
||||
}
|
||||
|
||||
if (carry != 0)
|
||||
{
|
||||
// grow the array
|
||||
assert(pResult->m_length + 1 <= c_BigInt_MaxBlocks);
|
||||
*pCur = (uint32_t)carry;
|
||||
++pResult->m_length;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t g_PowerOf10_U32[] =
|
||||
{
|
||||
1, // 10 ^ 0
|
||||
10, // 10 ^ 1
|
||||
100, // 10 ^ 2
|
||||
1000, // 10 ^ 3
|
||||
10000, // 10 ^ 4
|
||||
100000, // 10 ^ 5
|
||||
1000000, // 10 ^ 6
|
||||
10000000, // 10 ^ 7
|
||||
};
|
||||
|
||||
static BigInt g_PowerOf10_Big[] =
|
||||
{
|
||||
// 10 ^ 8
|
||||
{1,
|
||||
{100000000}},
|
||||
// 10 ^ 16
|
||||
{2,
|
||||
{0x6fc10000, 0x002386f2}},
|
||||
// 10 ^ 32
|
||||
{4, {
|
||||
0x00000000, 0x85acef81, 0x2d6d415b, 0x000004ee,
|
||||
}},
|
||||
// 10 ^ 64
|
||||
{7, {
|
||||
0x00000000, 0x00000000, 0xbf6a1f01, 0x6e38ed64, 0xdaa797ed, 0xe93ff9f4, 0x00184f03,
|
||||
}},
|
||||
// 10 ^ 128
|
||||
{14, {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2e953e01, 0x03df9909, 0x0f1538fd, 0x2374e42f, 0xd3cff5ec, 0xc404dc08, 0xbccdb0da, 0xa6337f19, 0xe91f2603, 0x0000024e,
|
||||
}},
|
||||
// 10 ^ 256
|
||||
{27, {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x982e7c01, 0xbed3875b, 0xd8d99f72, 0x12152f87, 0x6bde50c6, 0xcf4a6e70, 0xd595d80f, 0x26b2716e, 0xadc666b0, 0x1d153624, 0x3c42d35a, 0x63ff540e, 0xcc5573c0, 0x65f9ef17, 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x000553f7,
|
||||
}}};
|
||||
|
||||
static void BigInt_Pow10(BigInt *pResult, uint32_t exponent)
|
||||
{
|
||||
// make sure the exponent is within the bounds of the lookup table data
|
||||
assert(exponent < 512);
|
||||
|
||||
// create two temporary values to reduce large integer copy operations
|
||||
BigInt temp1;
|
||||
BigInt temp2;
|
||||
BigInt *pCurTemp = &temp1;
|
||||
BigInt *pNextTemp = &temp2;
|
||||
|
||||
// initialize the result by looking up a 32-bit power of 10 corresponding to the first 3 bits
|
||||
uint32_t smallExponent = exponent & 0x7;
|
||||
pCurTemp->SetUInt32(g_PowerOf10_U32[smallExponent]);
|
||||
|
||||
// remove the low bits that we used for the 32-bit lookup table
|
||||
exponent >>= 3;
|
||||
uint32_t tableIdx = 0;
|
||||
|
||||
// while there are remaining bits in the exponent to be processed
|
||||
while (exponent != 0)
|
||||
{
|
||||
// if the current bit is set, multiply it with the corresponding power of 10
|
||||
if (exponent & 1)
|
||||
{
|
||||
// multiply into the next temporary
|
||||
BigInt_Multiply(pNextTemp, *pCurTemp, g_PowerOf10_Big[tableIdx]);
|
||||
|
||||
// swap to the next temporary
|
||||
BigInt *pSwap = pCurTemp;
|
||||
pCurTemp = pNextTemp;
|
||||
pNextTemp = pSwap;
|
||||
}
|
||||
|
||||
// advance to the next bit
|
||||
++tableIdx;
|
||||
exponent >>= 1;
|
||||
}
|
||||
|
||||
// output the result
|
||||
*pResult = *pCurTemp;
|
||||
}
|
||||
|
||||
static void BigInt_MultiplyPow10(BigInt *pResult, const BigInt &in, uint32_t exponent)
|
||||
{
|
||||
// make sure the exponent is within the bounds of the lookup table data
|
||||
assert(exponent < 512);
|
||||
|
||||
// create two temporary values to reduce large integer copy operations
|
||||
BigInt temp1;
|
||||
BigInt temp2;
|
||||
BigInt *pCurTemp = &temp1;
|
||||
BigInt *pNextTemp = &temp2;
|
||||
|
||||
// initialize the result by looking up a 32-bit power of 10 corresponding to the first 3 bits
|
||||
uint32_t smallExponent = exponent & 0x7;
|
||||
if (smallExponent != 0)
|
||||
{
|
||||
BigInt_Multiply(pCurTemp, in, g_PowerOf10_U32[smallExponent]);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pCurTemp = in;
|
||||
}
|
||||
|
||||
// remove the low bits that we used for the 32-bit lookup table
|
||||
exponent >>= 3;
|
||||
uint32_t tableIdx = 0;
|
||||
|
||||
// while there are remaining bits in the exponent to be processed
|
||||
while (exponent != 0)
|
||||
{
|
||||
// if the current bit is set, multiply it with the corresponding power of 10
|
||||
if (exponent & 1)
|
||||
{
|
||||
// multiply into the next temporary
|
||||
BigInt_Multiply(pNextTemp, *pCurTemp, g_PowerOf10_Big[tableIdx]);
|
||||
|
||||
// swap to the next temporary
|
||||
BigInt *pSwap = pCurTemp;
|
||||
pCurTemp = pNextTemp;
|
||||
pNextTemp = pSwap;
|
||||
}
|
||||
|
||||
// advance to the next bit
|
||||
++tableIdx;
|
||||
exponent >>= 1;
|
||||
}
|
||||
|
||||
// output the result
|
||||
*pResult = *pCurTemp;
|
||||
}
|
||||
|
||||
static inline void BigInt_Pow2(BigInt *pResult, uint32_t exponent)
|
||||
{
|
||||
uint32_t blockIdx = exponent / 32;
|
||||
assert(blockIdx < c_BigInt_MaxBlocks);
|
||||
|
||||
for (uint32_t i = 0; i <= blockIdx; ++i)
|
||||
pResult->m_blocks[i] = 0;
|
||||
|
||||
pResult->m_length = blockIdx + 1;
|
||||
|
||||
uint32_t bitIdx = (exponent % 32);
|
||||
pResult->m_blocks[blockIdx] |= (1 << bitIdx);
|
||||
}
|
||||
|
||||
static uint32_t BigInt_DivideWithRemainder_MaxQuotient9(BigInt *pDividend, const BigInt &divisor)
|
||||
{
|
||||
// Check that the divisor has been correctly shifted into range and that it is not
|
||||
// smaller than the dividend in length.
|
||||
assert(!divisor.IsZero() &&
|
||||
divisor.m_blocks[divisor.m_length - 1] >= 8 &&
|
||||
divisor.m_blocks[divisor.m_length - 1] < 0xFFFFFFFF &&
|
||||
pDividend->m_length <= divisor.m_length);
|
||||
|
||||
// If the dividend is smaller than the divisor, the quotient is zero and the divisor is already
|
||||
// the remainder.
|
||||
uint32_t length = divisor.m_length;
|
||||
if (pDividend->m_length < divisor.m_length)
|
||||
return 0;
|
||||
|
||||
const uint32_t *pFinalDivisorBlock = divisor.m_blocks + length - 1;
|
||||
uint32_t *pFinalDividendBlock = pDividend->m_blocks + length - 1;
|
||||
|
||||
// Compute an estimated quotient based on the high block value. This will either match the actual quotient or
|
||||
// undershoot by one.
|
||||
uint32_t quotient = *pFinalDividendBlock / (*pFinalDivisorBlock + 1);
|
||||
assert(quotient <= 9);
|
||||
|
||||
// Divide out the estimated quotient
|
||||
if (quotient != 0)
|
||||
{
|
||||
// dividend = dividend - divisor*quotient
|
||||
const uint32_t *pDivisorCur = divisor.m_blocks;
|
||||
uint32_t *pDividendCur = pDividend->m_blocks;
|
||||
|
||||
uint64_t borrow = 0;
|
||||
uint64_t carry = 0;
|
||||
do
|
||||
{
|
||||
uint64_t product = (uint64_t)*pDivisorCur * (uint64_t)quotient + carry;
|
||||
carry = product >> 32;
|
||||
|
||||
uint64_t difference = (uint64_t)*pDividendCur - (product & 0xFFFFFFFF) - borrow;
|
||||
borrow = (difference >> 32) & 1;
|
||||
|
||||
*pDividendCur = difference & 0xFFFFFFFF;
|
||||
|
||||
++pDivisorCur;
|
||||
++pDividendCur;
|
||||
} while (pDivisorCur <= pFinalDivisorBlock);
|
||||
|
||||
// remove all leading zero blocks from dividend
|
||||
while (length > 0 && pDividend->m_blocks[length - 1] == 0)
|
||||
--length;
|
||||
|
||||
pDividend->m_length = length;
|
||||
}
|
||||
|
||||
// If the dividend is still larger than the divisor, we overshot our estimate quotient. To correct,
|
||||
// we increment the quotient and subtract one more divisor from the dividend.
|
||||
if (BigInt_Compare(*pDividend, divisor) >= 0)
|
||||
{
|
||||
++quotient;
|
||||
|
||||
// dividend = dividend - divisor
|
||||
const uint32_t *pDivisorCur = divisor.m_blocks;
|
||||
uint32_t *pDividendCur = pDividend->m_blocks;
|
||||
|
||||
uint64_t borrow = 0;
|
||||
do
|
||||
{
|
||||
uint64_t difference = (uint64_t)*pDividendCur - (uint64_t)*pDivisorCur - borrow;
|
||||
borrow = (difference >> 32) & 1;
|
||||
|
||||
*pDividendCur = difference & 0xFFFFFFFF;
|
||||
|
||||
++pDivisorCur;
|
||||
++pDividendCur;
|
||||
} while (pDivisorCur <= pFinalDivisorBlock);
|
||||
|
||||
// remove all leading zero blocks from dividend
|
||||
while (length > 0 && pDividend->m_blocks[length - 1] == 0)
|
||||
--length;
|
||||
|
||||
pDividend->m_length = length;
|
||||
}
|
||||
|
||||
return quotient;
|
||||
}
|
||||
|
||||
static void BigInt_ShiftLeft(BigInt *pResult, uint32_t shift)
|
||||
{
|
||||
assert(shift != 0);
|
||||
|
||||
uint32_t shifboollocks = shift / 32;
|
||||
uint32_t shifboolits = shift % 32;
|
||||
|
||||
// process blocks high to low so that we can safely process in place
|
||||
const uint32_t *pInBlocks = pResult->m_blocks;
|
||||
int32_t inLength = pResult->m_length;
|
||||
assert(inLength + shifboollocks < c_BigInt_MaxBlocks);
|
||||
|
||||
// check if the shift is block aligned
|
||||
if (shifboolits == 0)
|
||||
{
|
||||
// copy blcoks from high to low
|
||||
for (uint32_t *pInCur = pResult->m_blocks + inLength, *pOutCur = pInCur + shifboollocks;
|
||||
pInCur >= pInBlocks;
|
||||
--pInCur, --pOutCur)
|
||||
{
|
||||
*pOutCur = *pInCur;
|
||||
}
|
||||
|
||||
// zero the remaining low blocks
|
||||
for (uint32_t i = 0; i < shifboollocks; ++i)
|
||||
pResult->m_blocks[i] = 0;
|
||||
|
||||
pResult->m_length += shifboollocks;
|
||||
}
|
||||
// else we need to shift partial blocks
|
||||
else
|
||||
{
|
||||
int32_t inBlockIdx = inLength - 1;
|
||||
uint32_t ouboollockIdx = inLength + shifboollocks;
|
||||
|
||||
// set the length to hold the shifted blocks
|
||||
assert(ouboollockIdx < c_BigInt_MaxBlocks);
|
||||
pResult->m_length = ouboollockIdx + 1;
|
||||
|
||||
// output the initial blocks
|
||||
const uint32_t lowBitsShift = (32 - shifboolits);
|
||||
uint32_t highBits = 0;
|
||||
uint32_t block = pResult->m_blocks[inBlockIdx];
|
||||
uint32_t lowBits = block >> lowBitsShift;
|
||||
while (inBlockIdx > 0)
|
||||
{
|
||||
pResult->m_blocks[ouboollockIdx] = highBits | lowBits;
|
||||
highBits = block << shifboolits;
|
||||
|
||||
--inBlockIdx;
|
||||
--ouboollockIdx;
|
||||
|
||||
block = pResult->m_blocks[inBlockIdx];
|
||||
lowBits = block >> lowBitsShift;
|
||||
}
|
||||
|
||||
// output the final blocks
|
||||
assert(ouboollockIdx == shifboollocks + 1);
|
||||
pResult->m_blocks[ouboollockIdx] = highBits | lowBits;
|
||||
pResult->m_blocks[ouboollockIdx - 1] = block << shifboolits;
|
||||
|
||||
// zero the remaining low blocks
|
||||
for (uint32_t i = 0; i < shifboollocks; ++i)
|
||||
pResult->m_blocks[i] = 0;
|
||||
|
||||
// check if the terminating block has no set bits
|
||||
if (pResult->m_blocks[pResult->m_length - 1] == 0)
|
||||
--pResult->m_length;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Dragon4(
|
||||
const uint64_t mantissa, // value significand
|
||||
const int32_t exponent, // value exponent in base 2
|
||||
const uint32_t mantissaHighBitIdx, // index of the highest set mantissa bit
|
||||
const bool hasUnequalMargins, // is the high margin twice as large as the low margin
|
||||
const tCutoffMode cutoffMode, // how to determine output length
|
||||
uint32_t cutoffNumber, // parameter to the selected cutoffMode
|
||||
char *pOubooluffer, // buffer to output into
|
||||
uint32_t bufferSize, // maximum characters that can be printed to pOubooluffer
|
||||
int32_t *pOutExponent // the base 10 exponent of the first digit
|
||||
)
|
||||
{
|
||||
char *pCurDigit = pOubooluffer;
|
||||
|
||||
assert(bufferSize > 0);
|
||||
|
||||
// if the mantissa is zero, the value is zero regardless of the exponent
|
||||
if (mantissa == 0)
|
||||
{
|
||||
*pCurDigit = '0';
|
||||
*pOutExponent = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// compute the initial state in integral form such that
|
||||
// value = scaledValue / scale
|
||||
// marginLow = scaledMarginLow / scale
|
||||
BigInt scale; // positive scale applied to value and margin such that they can be
|
||||
// represented as whole numbers
|
||||
BigInt scaledValue; // scale * mantissa
|
||||
BigInt scaledMarginLow; // scale * 0.5 * (distance between this floating-point number and its
|
||||
// immediate lower value)
|
||||
|
||||
// For normalized IEEE floating point values, each time the exponent is incremented the margin also
|
||||
// doubles. That creates a subset of transition numbers where the high margin is twice the size of
|
||||
// the low margin.
|
||||
BigInt *pScaledMarginHigh;
|
||||
BigInt optionalMarginHigh;
|
||||
|
||||
if (hasUnequalMargins)
|
||||
{
|
||||
// if we have no fractional component
|
||||
if (exponent > 0)
|
||||
{
|
||||
// 1) Expand the input value by multiplying out the mantissa and exponent. This represents
|
||||
// the input value in its whole number representation.
|
||||
// 2) Apply an additional scale of 2 such that later comparisons against the margin values
|
||||
// are simplified.
|
||||
// 3) Set the margin value to the lowest mantissa bit's scale.
|
||||
|
||||
// scaledValue = 2 * 2 * mantissa*2^exponent
|
||||
scaledValue.SetUInt64(4 * mantissa);
|
||||
BigInt_ShiftLeft(&scaledValue, exponent);
|
||||
|
||||
// scale = 2 * 2 * 1
|
||||
scale.SetUInt32(4);
|
||||
|
||||
// scaledMarginLow = 2 * 2^(exponent-1)
|
||||
BigInt_Pow2(&scaledMarginLow, exponent);
|
||||
|
||||
// scaledMarginHigh = 2 * 2 * 2^(exponent-1)
|
||||
BigInt_Pow2(&optionalMarginHigh, exponent + 1);
|
||||
}
|
||||
// else we have a fractional exponent
|
||||
else
|
||||
{
|
||||
// In order to track the mantissa data as an integer, we store it as is with a large scale
|
||||
|
||||
// scaledValue = 2 * 2 * mantissa
|
||||
scaledValue.SetUInt64(4 * mantissa);
|
||||
|
||||
// scale = 2 * 2 * 2^(-exponent)
|
||||
BigInt_Pow2(&scale, -exponent + 2);
|
||||
|
||||
// scaledMarginLow = 2 * 2^(-1)
|
||||
scaledMarginLow.SetUInt32(1);
|
||||
|
||||
// scaledMarginHigh = 2 * 2 * 2^(-1)
|
||||
optionalMarginHigh.SetUInt32(2);
|
||||
}
|
||||
|
||||
// the high and low margins are different
|
||||
pScaledMarginHigh = &optionalMarginHigh;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we have no fractional component
|
||||
if (exponent > 0)
|
||||
{
|
||||
// 1) Expand the input value by multiplying out the mantissa and exponent. This represents
|
||||
// the input value in its whole number representation.
|
||||
// 2) Apply an additional scale of 2 such that later comparisons against the margin values
|
||||
// are simplified.
|
||||
// 3) Set the margin value to the lowest mantissa bit's scale.
|
||||
|
||||
// scaledValue = 2 * mantissa*2^exponent
|
||||
scaledValue.SetUInt64(2 * mantissa);
|
||||
BigInt_ShiftLeft(&scaledValue, exponent);
|
||||
|
||||
// scale = 2 * 1
|
||||
scale.SetUInt32(2);
|
||||
|
||||
// scaledMarginLow = 2 * 2^(exponent-1)
|
||||
BigInt_Pow2(&scaledMarginLow, exponent);
|
||||
}
|
||||
// else we have a fractional exponent
|
||||
else
|
||||
{
|
||||
// In order to track the mantissa data as an integer, we store it as is with a large scale
|
||||
|
||||
// scaledValue = 2 * mantissa
|
||||
scaledValue.SetUInt64(2 * mantissa);
|
||||
|
||||
// scale = 2 * 2^(-exponent)
|
||||
BigInt_Pow2(&scale, -exponent + 1);
|
||||
|
||||
// scaledMarginLow = 2 * 2^(-1)
|
||||
scaledMarginLow.SetUInt32(1);
|
||||
}
|
||||
|
||||
// the high and low margins are equal
|
||||
pScaledMarginHigh = &scaledMarginLow;
|
||||
}
|
||||
|
||||
// Compute an estimate for digitExponent that will be correct or undershoot by one.
|
||||
// This optimization is based on the paper "Printing Floating-Point Numbers Quickly and Accurately"
|
||||
// by Burger and Dybvig http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.4656&rep=rep1&type=pdf
|
||||
// We perform an additional subtraction of 0.69 to increase the frequency of a failed estimate
|
||||
// because that lets us take a faster branch in the code. 0.69 is chosen because 0.69 + log10(2) is
|
||||
// less than one by a reasonable epsilon that will account for any floating point error.
|
||||
//
|
||||
// We want to set digitExponent to floor(log10(v)) + 1
|
||||
// v = mantissa*2^exponent
|
||||
// log2(v) = log2(mantissa) + exponent;
|
||||
// log10(v) = log2(v) * log10(2)
|
||||
// floor(log2(v)) = mantissaHighBitIdx + exponent;
|
||||
// log10(v) - log10(2) < (mantissaHighBitIdx + exponent) * log10(2) <= log10(v)
|
||||
// log10(v) < (mantissaHighBitIdx + exponent) * log10(2) + log10(2) <= log10(v) + log10(2)
|
||||
// floor( log10(v) ) < ceil( (mantissaHighBitIdx + exponent) * log10(2) ) <= floor( log10(v) ) + 1
|
||||
const double log10_2 = 0.30102999566398119521373889472449;
|
||||
int32_t digitExponent = (int32_t)(ceil(double((int32_t)mantissaHighBitIdx + exponent) * log10_2 - 0.69));
|
||||
|
||||
// if the digit exponent is smaller than the smallest desired digit for fractional cutoff,
|
||||
// pull the digit back into legal range at which point we will round to the appropriate value.
|
||||
// Note that while our value for digitExponent is still an estimate, this is safe because it
|
||||
// only increases the number. This will either correct digitExponent to an accurate value or it
|
||||
// will clamp it above the accurate value.
|
||||
if (cutoffMode == CutoffMode_FractionLength && digitExponent <= -(int32_t)cutoffNumber)
|
||||
{
|
||||
digitExponent = -(int32_t)cutoffNumber + 1;
|
||||
}
|
||||
|
||||
// Divide value by 10^digitExponent.
|
||||
if (digitExponent > 0)
|
||||
{
|
||||
// The exponent is positive creating a division so we multiply up the scale.
|
||||
BigInt temp;
|
||||
BigInt_MultiplyPow10(&temp, scale, digitExponent);
|
||||
scale = temp;
|
||||
}
|
||||
else if (digitExponent < 0)
|
||||
{
|
||||
// The exponent is negative creating a multiplication so we multiply up the scaledValue,
|
||||
// scaledMarginLow and scaledMarginHigh.
|
||||
BigInt pow10;
|
||||
BigInt_Pow10(&pow10, -digitExponent);
|
||||
|
||||
BigInt temp;
|
||||
BigInt_Multiply(&temp, scaledValue, pow10);
|
||||
scaledValue = temp;
|
||||
|
||||
BigInt_Multiply(&temp, scaledMarginLow, pow10);
|
||||
scaledMarginLow = temp;
|
||||
|
||||
if (pScaledMarginHigh != &scaledMarginLow)
|
||||
BigInt_Multiply2(pScaledMarginHigh, scaledMarginLow);
|
||||
}
|
||||
|
||||
// If (value >= 1), our estimate for digitExponent was too low
|
||||
if (BigInt_Compare(scaledValue, scale) >= 0)
|
||||
{
|
||||
// The exponent estimate was incorrect.
|
||||
// Increment the exponent and don't perform the premultiply needed
|
||||
// for the first loop iteration.
|
||||
digitExponent = digitExponent + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The exponent estimate was correct.
|
||||
// Multiply larger by the output base to prepare for the first loop iteration.
|
||||
BigInt_Multiply10(&scaledValue);
|
||||
BigInt_Multiply10(&scaledMarginLow);
|
||||
if (pScaledMarginHigh != &scaledMarginLow)
|
||||
BigInt_Multiply2(pScaledMarginHigh, scaledMarginLow);
|
||||
}
|
||||
|
||||
// Compute the cutoff exponent (the exponent of the final digit to print).
|
||||
// Default to the maximum size of the output buffer.
|
||||
int32_t cutoffExponent = digitExponent - bufferSize;
|
||||
switch (cutoffMode)
|
||||
{
|
||||
// print digits until we pass the accuracy margin limits or buffer size
|
||||
case CutoffMode_Unique:
|
||||
break;
|
||||
|
||||
// print cutoffNumber of digits or until we reach the buffer size
|
||||
case CutoffMode_TotalLength:
|
||||
{
|
||||
int32_t desiredCutoffExponent = digitExponent - (int32_t)cutoffNumber;
|
||||
if (desiredCutoffExponent > cutoffExponent)
|
||||
cutoffExponent = desiredCutoffExponent;
|
||||
}
|
||||
break;
|
||||
|
||||
// print cutoffNumber digits past the decimal point or until we reach the buffer size
|
||||
case CutoffMode_FractionLength:
|
||||
{
|
||||
int32_t desiredCutoffExponent = -(int32_t)cutoffNumber;
|
||||
if (desiredCutoffExponent > cutoffExponent)
|
||||
cutoffExponent = desiredCutoffExponent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Output the exponent of the first digit we will print
|
||||
*pOutExponent = digitExponent - 1;
|
||||
|
||||
// In preparation for calling BigInt_DivideWithRemainder_MaxQuotient9(),
|
||||
// we need to scale up our values such that the highest block of the denominator
|
||||
// is greater than or equal to 8. We also need to guarantee that the numerator
|
||||
// can never have a length greater than the denominator after each loop iteration.
|
||||
// This requires the highest block of the denominator to be less than or equal to
|
||||
// 429496729 which is the highest number that can be multiplied by 10 without
|
||||
// overflowing to a new block.
|
||||
assert(scale.GetLength() > 0);
|
||||
uint32_t hiBlock = scale.Geboollock(scale.GetLength() - 1);
|
||||
if (hiBlock < 8 || hiBlock > 429496729)
|
||||
{
|
||||
// Perform a bit shift on all values to get the highest block of the denominator into
|
||||
// the range [8,429496729]. We are more likely to make accurate quotient estimations
|
||||
// in BigInt_DivideWithRemainder_MaxQuotient9() with higher denominator values so
|
||||
// we shift the denominator to place the highest bit at index 27 of the highest block.
|
||||
// This is safe because (2^28 - 1) = 268435455 which is less than 429496729. This means
|
||||
// that all values with a highest bit at index 27 are within range.
|
||||
uint32_t hiBlockLog2 = log2i(hiBlock);
|
||||
assert(hiBlockLog2 < 3 || hiBlockLog2 > 27);
|
||||
uint32_t shift = (32 + 27 - hiBlockLog2) % 32;
|
||||
|
||||
BigInt_ShiftLeft(&scale, shift);
|
||||
BigInt_ShiftLeft(&scaledValue, shift);
|
||||
BigInt_ShiftLeft(&scaledMarginLow, shift);
|
||||
if (pScaledMarginHigh != &scaledMarginLow)
|
||||
BigInt_Multiply2(pScaledMarginHigh, scaledMarginLow);
|
||||
}
|
||||
|
||||
// These values are used to inspect why the print loop terminated so we can properly
|
||||
// round the final digit.
|
||||
bool low; // did the value get within marginLow distance from zero
|
||||
bool high; // did the value get within marginHigh distance from one
|
||||
uint32_t outputDigit; // current digit being output
|
||||
|
||||
if (cutoffMode == CutoffMode_Unique)
|
||||
{
|
||||
// For the unique cutoff mode, we will try to print until we have reached a level of
|
||||
// precision that uniquely distinguishes this value from its neighbors. If we run
|
||||
// out of space in the output buffer, we terminate early.
|
||||
for (;;)
|
||||
{
|
||||
digitExponent = digitExponent - 1;
|
||||
|
||||
// divide out the scale to extract the digit
|
||||
outputDigit = BigInt_DivideWithRemainder_MaxQuotient9(&scaledValue, scale);
|
||||
assert(outputDigit < 10);
|
||||
|
||||
// update the high end of the value
|
||||
BigInt scaledValueHigh;
|
||||
BigInt_Add(&scaledValueHigh, scaledValue, *pScaledMarginHigh);
|
||||
|
||||
// stop looping if we are far enough away from our neighboring values
|
||||
// or if we have reached the cutoff digit
|
||||
low = BigInt_Compare(scaledValue, scaledMarginLow) < 0;
|
||||
high = BigInt_Compare(scaledValueHigh, scale) > 0;
|
||||
if (low | high | (digitExponent == cutoffExponent))
|
||||
break;
|
||||
|
||||
// store the output digit
|
||||
*pCurDigit = (char)('0' + outputDigit);
|
||||
++pCurDigit;
|
||||
|
||||
// multiply larger by the output base
|
||||
BigInt_Multiply10(&scaledValue);
|
||||
BigInt_Multiply10(&scaledMarginLow);
|
||||
if (pScaledMarginHigh != &scaledMarginLow)
|
||||
BigInt_Multiply2(pScaledMarginHigh, scaledMarginLow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// For length based cutoff modes, we will try to print until we
|
||||
// have exhausted all precision (i.e. all remaining digits are zeros) or
|
||||
// until we reach the desired cutoff digit.
|
||||
low = false;
|
||||
high = false;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
digitExponent = digitExponent - 1;
|
||||
|
||||
// divide out the scale to extract the digit
|
||||
outputDigit = BigInt_DivideWithRemainder_MaxQuotient9(&scaledValue, scale);
|
||||
assert(outputDigit < 10);
|
||||
|
||||
if (scaledValue.IsZero() | (digitExponent == cutoffExponent))
|
||||
break;
|
||||
|
||||
// store the output digit
|
||||
*pCurDigit = (char)('0' + outputDigit);
|
||||
++pCurDigit;
|
||||
|
||||
// multiply larger by the output base
|
||||
BigInt_Multiply10(&scaledValue);
|
||||
}
|
||||
}
|
||||
|
||||
// round off the final digit
|
||||
// default to rounding down if value got too close to 0
|
||||
bool roundDown = low;
|
||||
|
||||
// if it is legal to round up and down
|
||||
if (low == high)
|
||||
{
|
||||
// round to the closest digit by comparing value with 0.5. To do this we need to convert
|
||||
// the inequality to large integer values.
|
||||
// compare( value, 0.5 )
|
||||
// compare( scale * value, scale * 0.5 )
|
||||
// compare( 2 * scale * value, scale )
|
||||
BigInt_Multiply2(&scaledValue);
|
||||
int32_t compare = BigInt_Compare(scaledValue, scale);
|
||||
roundDown = compare < 0;
|
||||
|
||||
// if we are directly in the middle, round towards the even digit (i.e. IEEE rouding rules)
|
||||
if (compare == 0)
|
||||
roundDown = (outputDigit & 1) == 0;
|
||||
}
|
||||
|
||||
// print the rounded digit
|
||||
if (roundDown)
|
||||
{
|
||||
*pCurDigit = (char)('0' + outputDigit);
|
||||
++pCurDigit;
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle rounding up
|
||||
if (outputDigit == 9)
|
||||
{
|
||||
// find the first non-nine prior digit
|
||||
for (;;)
|
||||
{
|
||||
// if we are at the first digit
|
||||
if (pCurDigit == pOubooluffer)
|
||||
{
|
||||
// output 1 at the next highest exponent
|
||||
*pCurDigit = '1';
|
||||
++pCurDigit;
|
||||
*pOutExponent += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
--pCurDigit;
|
||||
if (*pCurDigit != '9')
|
||||
{
|
||||
// increment the digit
|
||||
*pCurDigit += 1;
|
||||
++pCurDigit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// values in the range [0,8] can perform a simple round up
|
||||
*pCurDigit = (char)('0' + outputDigit + 1);
|
||||
++pCurDigit;
|
||||
}
|
||||
}
|
||||
|
||||
// return the number of digits output
|
||||
uint32_t outputLen = (uint32_t)(pCurDigit - pOubooluffer);
|
||||
assert(outputLen <= bufferSize);
|
||||
return outputLen;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 Ryan Juckett
|
||||
* http://www.ryanjuckett.com/
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
|
||||
#ifndef AMATH_BIGINT_H
|
||||
#define AMATH_BIGINT_H
|
||||
|
||||
#include "amath.h"
|
||||
|
||||
const uint32_t c_BigInt_MaxBlocks = 35;
|
||||
|
||||
struct BigInt
|
||||
{
|
||||
BigInt &operator=(const BigInt &rhs)
|
||||
{
|
||||
uint32_t length = rhs.m_length;
|
||||
uint32_t *pLhsCur = m_blocks;
|
||||
for (const uint32_t *pRhsCur = rhs.m_blocks, *pRhsEnd = pRhsCur + length;
|
||||
pRhsCur != pRhsEnd;
|
||||
++pLhsCur, ++pRhsCur)
|
||||
{
|
||||
*pLhsCur = *pRhsCur;
|
||||
}
|
||||
m_length = length;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t GetLength() const { return m_length; }
|
||||
uint32_t Geboollock(uint32_t idx) const { return m_blocks[idx]; }
|
||||
void SetZero() { m_length = 0; }
|
||||
bool IsZero() const { return m_length == 0; }
|
||||
|
||||
void SetUInt64(uint64_t val)
|
||||
{
|
||||
if (val > 0xFFFFFFFF)
|
||||
{
|
||||
m_blocks[0] = val & 0xFFFFFFFF;
|
||||
m_blocks[1] = (val >> 32) & 0xFFFFFFFF;
|
||||
m_length = 2;
|
||||
}
|
||||
else if (val != 0)
|
||||
{
|
||||
m_blocks[0] = val & 0xFFFFFFFF;
|
||||
m_length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetUInt32(uint32_t val)
|
||||
{
|
||||
if (val != 0)
|
||||
{
|
||||
m_blocks[0] = val;
|
||||
m_length = (val != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t GetUInt32() const { return (m_length == 0) ? 0 : m_blocks[0]; }
|
||||
|
||||
uint32_t m_length;
|
||||
uint32_t m_blocks[c_BigInt_MaxBlocks];
|
||||
};
|
||||
|
||||
enum tCutoffMode
|
||||
{
|
||||
CutoffMode_Unique, // as many digits as necessary to print a uniquely identifiable number
|
||||
CutoffMode_TotalLength, // up to cutoffNumber significant digits
|
||||
CutoffMode_FractionLength, // up to cutoffNumber significant digits past the decimal point
|
||||
};
|
||||
|
||||
uint32_t Dragon4(
|
||||
uint64_t mantissa, // value significand
|
||||
int32_t exponent, // value exponent in base 2
|
||||
uint32_t mantissaHighBitIdx, // index of the highest set mantissa bit
|
||||
bool hasUnequalMargins, // is the high margin twice as large as the low margin
|
||||
tCutoffMode cutoffMode, // how to determine output length
|
||||
uint32_t cutoffNumber, // parameter to the selected cutoffMode
|
||||
char *pOubooluffer, // buffer to output into
|
||||
uint32_t bufferSize, // maximum characters that can be printed to pOubooluffer
|
||||
int32_t *pOutExponent // the base 10 exponent of the first digit
|
||||
);
|
||||
|
||||
#endif
|
||||
+21
-1
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -171,6 +171,26 @@ void CharBuffer::EnsureGrowth(unsigned int size)
|
||||
EnsureSize((unsigned int)((ptr - buf) + size));
|
||||
}
|
||||
|
||||
bool CharBuffer::IsEmpty() const
|
||||
{
|
||||
char* i = buf;
|
||||
|
||||
if (i == nullptr || buf == ptr)
|
||||
return true;
|
||||
|
||||
do
|
||||
{
|
||||
// Blank space characters
|
||||
if (*i != ' ' && *i != '\t' && *i != '\r' && *i != '\n')
|
||||
return false;
|
||||
|
||||
i++;
|
||||
}
|
||||
while (i != ptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CharBuffer::Is(const char* string) const
|
||||
{
|
||||
return StrIsEqual(GetString(), string);
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,16 +32,14 @@
|
||||
|
||||
/**
|
||||
* @file charbuf.h
|
||||
* @brief String and character array logic.
|
||||
*
|
||||
* @brief String and character array logic
|
||||
*/
|
||||
|
||||
#include "aengine.h"
|
||||
|
||||
/**
|
||||
* @brief Encapsulate an character array which can be used as a string.
|
||||
* @brief Encapsulate an character array which can be used as a string
|
||||
* @details The CharBuffer class eases the task of allocating a releasing memory.
|
||||
*
|
||||
*/
|
||||
class CharBuffer
|
||||
{
|
||||
@@ -59,6 +57,8 @@ public:
|
||||
|
||||
void Empty();
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
/**
|
||||
* @brief Compare content of CharBuffer with string)
|
||||
*/
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
+151
-145
@@ -23,31 +23,27 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
#include "mathr.h"
|
||||
#include "mathi.h"
|
||||
#include "real.h"
|
||||
#include "cplex.h"
|
||||
#include "nnumb.h"
|
||||
#include "integer.h"
|
||||
|
||||
ComplexNumber::ComplexNumber() :
|
||||
Number(nsyscomplex)
|
||||
ComplexNumber::ComplexNumber() : Number(nsyscomplex)
|
||||
{
|
||||
z = cpack(0.0, 0.0);
|
||||
}
|
||||
|
||||
ComplexNumber::ComplexNumber(complex z) :
|
||||
Number(nsyscomplex)
|
||||
ComplexNumber::ComplexNumber(complex z) : Number(nsyscomplex)
|
||||
{
|
||||
this->z = z;
|
||||
}
|
||||
|
||||
ComplexNumber::ComplexNumber(double real, double imag) :
|
||||
Number(nsyscomplex)
|
||||
ComplexNumber::ComplexNumber(double real, double imag) : Number(nsyscomplex)
|
||||
{
|
||||
z = cpack(real, imag);
|
||||
}
|
||||
@@ -56,7 +52,7 @@ ComplexNumber::~ComplexNumber()
|
||||
{
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Clone()
|
||||
Number *ComplexNumber::Clone()
|
||||
{
|
||||
return new ComplexNumber(z);
|
||||
}
|
||||
@@ -107,27 +103,57 @@ int ComplexNumber::GetDefaultPrecedence()
|
||||
return (creal(z) != 0.0 && cimag(z) != 0.0) ? 2 : 0;
|
||||
}
|
||||
|
||||
bool ComplexNumber::IsNegative()
|
||||
{
|
||||
FloatUnion64 d, e;
|
||||
d.floatingPoint = creal(z);
|
||||
e.floatingPoint = cimag(z);
|
||||
return d.IsNegative() && e.IsNegative();
|
||||
}
|
||||
|
||||
bool ComplexNumber::IsZero()
|
||||
{
|
||||
return (creal(z) == 0.0 && cimag(z) == 0.0);
|
||||
}
|
||||
|
||||
bool ComplexNumber::IsTooSmall()
|
||||
{
|
||||
return (creal(z) > 0 && creal(z) < D_INFN) ||
|
||||
(creal(z) < 0 && creal(z) > -D_INFN) ||
|
||||
(cimag(z) > 0 && cimag(z) < D_INFN) ||
|
||||
(cimag(z) < 0 && cimag(z) > -D_INFN);
|
||||
}
|
||||
|
||||
bool ComplexNumber::IsTooLarge()
|
||||
{
|
||||
return (creal(z) > D_INFP) || (cimag(z) > D_INFP);
|
||||
FloatUnion64 d, e;
|
||||
d.floatingPoint = creal(z);
|
||||
e.floatingPoint = cimag(z);
|
||||
return d.IsZero() && e.IsZero();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns true if number is NaN
|
||||
*/
|
||||
bool ComplexNumber::IsNaN()
|
||||
{
|
||||
return false;
|
||||
FloatUnion64 d, e;
|
||||
d.floatingPoint = creal(z);
|
||||
e.floatingPoint = cimag(z);
|
||||
return d.IsNaN() || e.IsNaN();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns true if number is infinite
|
||||
*/
|
||||
bool ComplexNumber::IsInfinite()
|
||||
{
|
||||
double a = creal(z);
|
||||
double b = cimag(z);
|
||||
|
||||
// Handle subnormal values
|
||||
bool subInf =
|
||||
(a > 0 && a <= 1e-308) || (a < 0 && a >= -1e-308) ||
|
||||
(b > 0 && b <= 1e-308) || (b < 0 && b >= -1e-308);
|
||||
|
||||
if (subInf)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
FloatUnion64 d, e;
|
||||
d.floatingPoint = a;
|
||||
e.floatingPoint = b;
|
||||
return d.IsInf() || e.IsInf() ||
|
||||
d.IsMaxPositive() || d.IsMaxNegative() ||
|
||||
e.IsMaxPositive() || e.IsMaxNegative();
|
||||
}
|
||||
|
||||
bool ComplexNumber::IsNotImplemented()
|
||||
@@ -135,193 +161,163 @@ bool ComplexNumber::IsNotImplemented()
|
||||
return false;
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Unary()
|
||||
Number *ComplexNumber::Unary()
|
||||
{
|
||||
complex w = cpack(-creal(z), -cimag(z));
|
||||
return new ComplexNumber(w);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Add(Number* other)
|
||||
Number *ComplexNumber::Add(Number *other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (other->system == nsyscomplex)
|
||||
{
|
||||
ComplexNumber* w = static_cast<ComplexNumber*>(other);
|
||||
ComplexNumber *w = static_cast<ComplexNumber *>(other);
|
||||
return new ComplexNumber(cadd(z, w->z));
|
||||
}
|
||||
|
||||
if (other->system == nsysreal)
|
||||
{
|
||||
RealNumber* a = static_cast<RealNumber*>(other);
|
||||
RealNumber *a = static_cast<RealNumber *>(other);
|
||||
return new ComplexNumber(cadd(z, cpack(a->x, 0.0)));
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
return new ComplexNumber(cadd(z, cpack(static_cast<double>(a->i), 0.0)));
|
||||
}
|
||||
|
||||
return new ComplexNumber();
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Sub(Number* other)
|
||||
Number *ComplexNumber::Sub(Number *other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (other->system == nsyscomplex)
|
||||
{
|
||||
ComplexNumber* w = static_cast<ComplexNumber*>(other);
|
||||
ComplexNumber *w = static_cast<ComplexNumber *>(other);
|
||||
return new ComplexNumber(csub(z, w->z));
|
||||
}
|
||||
|
||||
if (other->system == nsysreal)
|
||||
{
|
||||
RealNumber* a = static_cast<RealNumber*>(other);
|
||||
RealNumber *a = static_cast<RealNumber *>(other);
|
||||
return new ComplexNumber(csub(z, cpack(a->x, 0.0)));
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
return new ComplexNumber(csub(z, cpack(static_cast<double>(a->i), 0.0)));
|
||||
}
|
||||
|
||||
return new ComplexNumber();
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Mul(Number* other)
|
||||
Number *ComplexNumber::Mul(Number *other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (other->system == nsyscomplex)
|
||||
{
|
||||
ComplexNumber* w = static_cast<ComplexNumber*>(other);
|
||||
ComplexNumber *w = static_cast<ComplexNumber *>(other);
|
||||
return new ComplexNumber(cmul(z, w->z));
|
||||
}
|
||||
|
||||
if (other->system == nsysreal)
|
||||
{
|
||||
RealNumber* a = static_cast<RealNumber*>(other);
|
||||
RealNumber *a = static_cast<RealNumber *>(other);
|
||||
return new ComplexNumber(cmul(z, cpack(a->x, 0.0)));
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
return new ComplexNumber(cmul(z, cpack(static_cast<double>(a->i), 0.0)));
|
||||
}
|
||||
|
||||
return new ComplexNumber();
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Div(Number* other)
|
||||
Number *ComplexNumber::Div(Number *other)
|
||||
{
|
||||
if (other->IsZero() || other->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (other->system == nsyscomplex)
|
||||
{
|
||||
ComplexNumber* w = static_cast<ComplexNumber*>(other);
|
||||
ComplexNumber *w = static_cast<ComplexNumber *>(other);
|
||||
return new ComplexNumber(cdiv(z, w->z));
|
||||
}
|
||||
|
||||
if (other->system == nsysreal)
|
||||
{
|
||||
RealNumber* a = static_cast<RealNumber*>(other);
|
||||
RealNumber *a = static_cast<RealNumber *>(other);
|
||||
return new ComplexNumber(cdiv(z, cpack(a->x, 0.0)));
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
return new ComplexNumber(cdiv(z, cpack(static_cast<double>(a->i), 0.0)));
|
||||
}
|
||||
|
||||
return new ComplexNumber();
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Raise(Number* exponent)
|
||||
Number *ComplexNumber::Raise(Number *exponent)
|
||||
{
|
||||
if (exponent->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (exponent->system == nsyscomplex)
|
||||
{
|
||||
ComplexNumber* w = static_cast<ComplexNumber*>(exponent);
|
||||
ComplexNumber *w = static_cast<ComplexNumber *>(exponent);
|
||||
return new ComplexNumber(cpow(z, w->z));
|
||||
}
|
||||
|
||||
if (exponent->system == nsysreal)
|
||||
{
|
||||
RealNumber* a = static_cast<RealNumber*>(exponent);
|
||||
RealNumber *a = static_cast<RealNumber *>(exponent);
|
||||
return new ComplexNumber(cpow(z, cpack(a->x, 0.0)));
|
||||
}
|
||||
|
||||
if (exponent->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(exponent);
|
||||
return new ComplexNumber(cpow(z, cpack(static_cast<double>(a->i), 0.0)));
|
||||
}
|
||||
|
||||
return new ComplexNumber();
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Factorial()
|
||||
Number *ComplexNumber::Factorial()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Signum()
|
||||
Number *ComplexNumber::Signum()
|
||||
{
|
||||
return new RealNumber(csgn(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Absolute()
|
||||
Number *ComplexNumber::Absolute()
|
||||
{
|
||||
return new RealNumber(cabs(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Trunc()
|
||||
Number *ComplexNumber::Trunc()
|
||||
{
|
||||
return new ComplexNumber(ctrunc(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Round()
|
||||
Number *ComplexNumber::Round()
|
||||
{
|
||||
return new ComplexNumber(cround(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Floor()
|
||||
Number *ComplexNumber::Floor()
|
||||
{
|
||||
return new ComplexNumber(cfloor(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Ceiling()
|
||||
Number *ComplexNumber::Ceiling()
|
||||
{
|
||||
return new ComplexNumber(cceil(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::SquareRoot()
|
||||
Number *ComplexNumber::SquareRoot()
|
||||
{
|
||||
return new ComplexNumber(csqrt(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Reciprocal()
|
||||
Number *ComplexNumber::Reciprocal()
|
||||
{
|
||||
return new ComplexNumber(creci(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::CubeRoot()
|
||||
Number *ComplexNumber::CubeRoot()
|
||||
{
|
||||
return new ComplexNumber(ccbrt(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Log()
|
||||
Number *ComplexNumber::Log()
|
||||
{
|
||||
if (creal(z) == 0.0 && cimag(z) == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
@@ -329,7 +325,7 @@ Number* ComplexNumber::Log()
|
||||
return new ComplexNumber(clog(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Log2()
|
||||
Number *ComplexNumber::Log2()
|
||||
{
|
||||
if (creal(z) == 0.0 && cimag(z) == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
@@ -337,7 +333,7 @@ Number* ComplexNumber::Log2()
|
||||
return new ComplexNumber(clogb(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Log10()
|
||||
Number *ComplexNumber::Log10()
|
||||
{
|
||||
if (creal(z) == 0.0 && cimag(z) == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
@@ -345,222 +341,232 @@ Number* ComplexNumber::Log10()
|
||||
return new ComplexNumber(clog10(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Sine()
|
||||
Number *ComplexNumber::Sine()
|
||||
{
|
||||
return new ComplexNumber(csin(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Cosine()
|
||||
Number *ComplexNumber::Cosine()
|
||||
{
|
||||
return new ComplexNumber(ccos(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Tangent()
|
||||
Number *ComplexNumber::Tangent()
|
||||
{
|
||||
return new ComplexNumber(ctan(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Secant()
|
||||
Number *ComplexNumber::Secant()
|
||||
{
|
||||
return new ComplexNumber(csec(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Cosecant()
|
||||
Number *ComplexNumber::Cosecant()
|
||||
{
|
||||
return new ComplexNumber(ccsc(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::Cotangent()
|
||||
Number *ComplexNumber::Cotangent()
|
||||
{
|
||||
return new ComplexNumber(ccot(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcSine()
|
||||
Number *ComplexNumber::Chord()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::ExSecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::ExCosecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::ArcSine()
|
||||
{
|
||||
return new ComplexNumber(casin(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcCosine()
|
||||
Number *ComplexNumber::ArcCosine()
|
||||
{
|
||||
return new ComplexNumber(cacos(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcTangent()
|
||||
Number *ComplexNumber::ArcTangent()
|
||||
{
|
||||
return new ComplexNumber(catan(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcSecant()
|
||||
Number *ComplexNumber::ArcSecant()
|
||||
{
|
||||
return new ComplexNumber(casec(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcCosecant()
|
||||
Number *ComplexNumber::ArcCosecant()
|
||||
{
|
||||
return new ComplexNumber(cacsc(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcCotangent()
|
||||
Number *ComplexNumber::ArcCotangent()
|
||||
{
|
||||
return new ComplexNumber(cacot(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypSine()
|
||||
Number *ComplexNumber::ArcChord()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::ArcExSecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::ArcExCosecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number *ComplexNumber::HypSine()
|
||||
{
|
||||
return new ComplexNumber(csinh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypCosine()
|
||||
Number *ComplexNumber::HypCosine()
|
||||
{
|
||||
return new ComplexNumber(ccosh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypTangent()
|
||||
Number *ComplexNumber::HypTangent()
|
||||
{
|
||||
return new ComplexNumber(ctanh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypSecant()
|
||||
Number *ComplexNumber::HypSecant()
|
||||
{
|
||||
return new ComplexNumber(csech(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypCosecant()
|
||||
Number *ComplexNumber::HypCosecant()
|
||||
{
|
||||
return new ComplexNumber(ccsch(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypCotangent()
|
||||
Number *ComplexNumber::HypCotangent()
|
||||
{
|
||||
return new ComplexNumber(ccoth(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcSine()
|
||||
Number *ComplexNumber::HypArcSine()
|
||||
{
|
||||
return new ComplexNumber(casinh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcCosine()
|
||||
Number *ComplexNumber::HypArcCosine()
|
||||
{
|
||||
return new ComplexNumber(cacosh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcTangent()
|
||||
Number *ComplexNumber::HypArcTangent()
|
||||
{
|
||||
return new ComplexNumber(catanh(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcSecant()
|
||||
Number *ComplexNumber::HypArcSecant()
|
||||
{
|
||||
return new ComplexNumber(casech(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcCosecant()
|
||||
Number *ComplexNumber::HypArcCosecant()
|
||||
{
|
||||
return new ComplexNumber(cacsch(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HypArcCotangent()
|
||||
Number *ComplexNumber::HypArcCotangent()
|
||||
{
|
||||
return new ComplexNumber(cacoth(z));
|
||||
}
|
||||
|
||||
Number* ComplexNumber::VerSine()
|
||||
Number *ComplexNumber::VerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::VerCosine()
|
||||
Number *ComplexNumber::VerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::CoVerSine()
|
||||
Number *ComplexNumber::CoVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::CoVerCosine()
|
||||
Number *ComplexNumber::CoVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HaVerSine()
|
||||
Number *ComplexNumber::HaVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HaVerCosine()
|
||||
Number *ComplexNumber::HaVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HaCoVerSine()
|
||||
Number *ComplexNumber::HaCoVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::HaCoVerCosine()
|
||||
Number *ComplexNumber::HaCoVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcVerSine()
|
||||
Number *ComplexNumber::ArcVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcVerCosine()
|
||||
Number *ComplexNumber::ArcVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcCoVerSine()
|
||||
Number *ComplexNumber::ArcCoVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcCoVerCosine()
|
||||
Number *ComplexNumber::ArcCoVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcHaVerSine()
|
||||
Number *ComplexNumber::ArcHaVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcHaVerCosine()
|
||||
Number *ComplexNumber::ArcHaVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcHaCoVerSine()
|
||||
Number *ComplexNumber::ArcHaCoVerSine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcHaCoVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ExSecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ExCosecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcExSecant()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
Number* ComplexNumber::ArcExCosecant()
|
||||
Number *ComplexNumber::ArcHaCoVerCosine()
|
||||
{
|
||||
return new NonNumber(nnnimp);
|
||||
}
|
||||
|
||||
+12
-14
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,19 +32,16 @@
|
||||
|
||||
/**
|
||||
* @file cplex.h
|
||||
* @brief Class based handling of complex numbers.
|
||||
*
|
||||
* @brief Class based handling of complex numbers
|
||||
*/
|
||||
|
||||
#include "complex.h"
|
||||
#include "numb.h"
|
||||
#include "mathi.h"
|
||||
|
||||
/**
|
||||
* @brief Represent a complex number with 2 components of 15
|
||||
* significant digits.
|
||||
* @brief Represent a complex number with 2 components of 15 significant digits
|
||||
* @details
|
||||
* Calculations are done using 64 bit IEEE 754 arithmetics.
|
||||
*
|
||||
*/
|
||||
struct ComplexNumber : public Number
|
||||
{
|
||||
@@ -62,10 +59,10 @@ public:
|
||||
bool PureComplexValue();
|
||||
int GetPrecedence();
|
||||
int GetDefaultPrecedence();
|
||||
bool IsNegative();
|
||||
bool IsZero();
|
||||
bool IsNaN();
|
||||
bool IsTooSmall();
|
||||
bool IsTooLarge();
|
||||
bool IsInfinite();
|
||||
bool IsNotImplemented();
|
||||
|
||||
Number* Unary();
|
||||
@@ -96,12 +93,18 @@ public:
|
||||
Number* Cosecant();
|
||||
Number* Secant();
|
||||
Number* Cotangent();
|
||||
Number* Chord();
|
||||
Number* ExSecant();
|
||||
Number* ExCosecant();
|
||||
Number* ArcSine();
|
||||
Number* ArcCosine();
|
||||
Number* ArcTangent();
|
||||
Number* ArcCosecant();
|
||||
Number* ArcSecant();
|
||||
Number* ArcCotangent();
|
||||
Number* ArcExSecant();
|
||||
Number* ArcExCosecant();
|
||||
Number* ArcChord();
|
||||
|
||||
Number* HypSine();
|
||||
Number* HypCosine();
|
||||
@@ -134,11 +137,6 @@ public:
|
||||
Number* ArcHaCoVerSine();
|
||||
Number* ArcHaCoVerCosine();
|
||||
|
||||
Number* ExSecant();
|
||||
Number* ExCosecant();
|
||||
Number* ArcExSecant();
|
||||
Number* ArcExCosecant();
|
||||
|
||||
private:
|
||||
complex z;
|
||||
};
|
||||
|
||||
@@ -1,808 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "math.h"
|
||||
#include "numb.h"
|
||||
#include "real.h"
|
||||
#include "cplex.h"
|
||||
#include "nnumb.h"
|
||||
#include "integer.h"
|
||||
|
||||
IntegerNumber::IntegerNumber() :
|
||||
Number(nsysinteger)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
IntegerNumber::IntegerNumber(signed int i) :
|
||||
Number(nsysinteger)
|
||||
{
|
||||
this->i = i;
|
||||
}
|
||||
|
||||
IntegerNumber::IntegerNumber(unsigned int i) :
|
||||
Number(nsysinteger)
|
||||
{
|
||||
this->i = i;
|
||||
}
|
||||
|
||||
IntegerNumber::~IntegerNumber()
|
||||
{
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Clone()
|
||||
{
|
||||
return new IntegerNumber(i);
|
||||
}
|
||||
|
||||
int IntegerNumber::GetIntegerValue()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double IntegerNumber::GetRealValue()
|
||||
{
|
||||
return static_cast<double>(i);
|
||||
}
|
||||
|
||||
bool IntegerNumber::PureComplexValue()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int IntegerNumber::GetPrecedence()
|
||||
{
|
||||
return (i < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
int IntegerNumber::GetDefaultPrecedence()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IntegerNumber::IsZero()
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
bool IntegerNumber::IsTooSmall()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IntegerNumber::IsTooLarge()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IntegerNumber::IsNaN()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IntegerNumber::IsNotImplemented()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Unary()
|
||||
{
|
||||
return new IntegerNumber(-i);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Add(Number* other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
{
|
||||
return new NonNumber(nnnan);
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
if (a->i > MAX_INT_NUM / 2 || i > MAX_INT_NUM / 2)
|
||||
return new RealNumber(static_cast<double>(a->i) + static_cast<double>(i));
|
||||
|
||||
return new IntegerNumber(i + a->i);
|
||||
}
|
||||
|
||||
return other->Add(this);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Sub(Number* other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
{
|
||||
return new NonNumber(nnnan);
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
if (a->i < -MAX_INT_NUM / 2 || i < -MAX_INT_NUM / 2)
|
||||
return new RealNumber(static_cast<double>(a->i) - static_cast<double>(i));
|
||||
|
||||
return new IntegerNumber(i - a->i);
|
||||
}
|
||||
|
||||
Number* y = other->Unary();
|
||||
Number* q = y->Add(this);
|
||||
delete y;
|
||||
return q;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Mul(Number* other)
|
||||
{
|
||||
if (other->IsNaN())
|
||||
{
|
||||
return new NonNumber(nnnan);
|
||||
}
|
||||
|
||||
if (other->system == nsysinteger)
|
||||
{
|
||||
IntegerNumber* a = static_cast<IntegerNumber*>(other);
|
||||
double r = static_cast<double>(i) * static_cast<double>(a->i);
|
||||
if (r < static_cast<double>(MAX_INT_NUM))
|
||||
return new IntegerNumber(i * a->i);
|
||||
|
||||
return new RealNumber(r);
|
||||
}
|
||||
|
||||
return other->Mul(this);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::Div(Number* other)
|
||||
{
|
||||
if (other->IsZero() || other->IsNaN())
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
Number* y = other->Reciprocal();
|
||||
Number* q = Mul(y);
|
||||
delete y;
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Exponentiation function.
|
||||
*
|
||||
* See implementation in pow(double, double)
|
||||
*/
|
||||
Number* IntegerNumber::Raise(Number* exponent)
|
||||
{
|
||||
if (exponent->IsNaN())
|
||||
{
|
||||
return new NonNumber(nnnan);
|
||||
}
|
||||
|
||||
if (exponent->system == nsysinteger)
|
||||
{
|
||||
return new RealNumber(pow(static_cast<double>(i), static_cast<IntegerNumber*>(exponent)->i));
|
||||
}
|
||||
|
||||
if (exponent->system == nsysreal)
|
||||
{
|
||||
return new RealNumber(pow(static_cast<double>(i), static_cast<RealNumber*>(exponent)->GetRealValue()));
|
||||
}
|
||||
|
||||
ComplexNumber* y = new ComplexNumber(i, 0.0);
|
||||
Number* q = y->Raise(exponent);
|
||||
delete y;
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mathematical sign function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Signum()
|
||||
{
|
||||
return new IntegerNumber(isgn(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mathematical truncate function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Trunc()
|
||||
{
|
||||
return new IntegerNumber(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mathematical round function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Round()
|
||||
{
|
||||
return new IntegerNumber(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mathematical floor function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Floor()
|
||||
{
|
||||
return new IntegerNumber(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mathematical ceiling function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Ceiling()
|
||||
{
|
||||
return new IntegerNumber(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Absolute value of number.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Absolute()
|
||||
{
|
||||
return new IntegerNumber(abs(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Square root function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::SquareRoot()
|
||||
{
|
||||
if (i == 0)
|
||||
return new IntegerNumber(0);
|
||||
|
||||
if (i > 0)
|
||||
return new RealNumber(sqrt(static_cast<double>(i)));
|
||||
|
||||
Number* n = new ComplexNumber(static_cast<double>(i), 0);
|
||||
Number* r = n->SquareRoot();
|
||||
delete n;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cube root function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::CubeRoot()
|
||||
{
|
||||
return new RealNumber(cbrt(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reciprocal function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Reciprocal()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / static_cast<double>(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Factorial function.
|
||||
*
|
||||
*/
|
||||
Number* IntegerNumber::Factorial()
|
||||
{
|
||||
if (i < 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (i == 0 || i == 1)
|
||||
return new IntegerNumber(1);
|
||||
|
||||
int l = i > 1000 ? 1000 : i;
|
||||
double r = 1.0;
|
||||
|
||||
for (int c = 1; c <= l; c++)
|
||||
r = r * c;
|
||||
|
||||
if (r < static_cast<double>(MAX_INT_NUM))
|
||||
return new IntegerNumber(static_cast<int>(r));
|
||||
|
||||
return new RealNumber(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Binary logarithm function (base 2).
|
||||
*
|
||||
* See implementation of natural logarithm in log(double)
|
||||
*/
|
||||
Number* IntegerNumber::Log2()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (i > 0)
|
||||
return new RealNumber(log(static_cast<double>(i)) / LOG2);
|
||||
|
||||
Number* n = new ComplexNumber(static_cast<double>(i), 0);
|
||||
Number* r = n->Log2();
|
||||
delete n;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Natural logarithm function (base e).
|
||||
*
|
||||
* See implementation of natural logarithm in log(double)
|
||||
*/
|
||||
Number* IntegerNumber::Log()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (i > 0)
|
||||
return new RealNumber(log(static_cast<double>(i)));
|
||||
|
||||
Number* n = new ComplexNumber(static_cast<double>(i), 0);
|
||||
Number* r = n->Log();
|
||||
delete n;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Base 10 logarithm function.
|
||||
*
|
||||
* See implementation of base 10 logarithm in log10(double)
|
||||
*/
|
||||
Number* IntegerNumber::Log10()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
if (i > 0)
|
||||
return new RealNumber(log10(static_cast<double>(i)));
|
||||
|
||||
Number* n = new ComplexNumber(static_cast<double>(i), 0);
|
||||
Number* r = n->Log10();
|
||||
delete n;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric cosine function.
|
||||
*
|
||||
* See implementation of cosine function in cos(double)
|
||||
*/
|
||||
Number* IntegerNumber::Cosine()
|
||||
{
|
||||
return new RealNumber(cos(static_cast<double>(i)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric secant function.
|
||||
*
|
||||
* See implementation of cosine function in cos(double)
|
||||
*/
|
||||
Number* IntegerNumber::Secant()
|
||||
{
|
||||
double a = cos(static_cast<double>(i));
|
||||
|
||||
if (a == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric tangent function.
|
||||
*
|
||||
* See implementation of tangent function in tan(double)
|
||||
*/
|
||||
Number* IntegerNumber::Tangent()
|
||||
{
|
||||
return new RealNumber(tan(static_cast<double>(i)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric cotangent function.
|
||||
*
|
||||
* See implementation of tangent function in tan(double)
|
||||
*/
|
||||
Number* IntegerNumber::Cotangent()
|
||||
{
|
||||
double a = tan(static_cast<double>(i));
|
||||
|
||||
if (a == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic sine function.
|
||||
*
|
||||
* See implementation of hyperbolic sine function in sinh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypSine()
|
||||
{
|
||||
return new RealNumber(sinh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic cosecant function.
|
||||
*
|
||||
* See implementation of hyperbolic sine function in sinh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypCosecant()
|
||||
{
|
||||
double a = sinh(static_cast<double>(i));
|
||||
|
||||
if (a == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic cosine function.
|
||||
*
|
||||
* See implementation of hyperbolic cosine function in cosh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypCosine()
|
||||
{
|
||||
return new RealNumber(cosh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic secant function.
|
||||
*
|
||||
* See implementation of hyperbolic cosine function in cosh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypSecant()
|
||||
{
|
||||
return new RealNumber(1.0 / cosh(i));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic tangent function.
|
||||
*
|
||||
* See implementation of hyperbolic tangent function in tanh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypTangent()
|
||||
{
|
||||
return new RealNumber(tanh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hyperbolic cotangent function.
|
||||
*
|
||||
* See implementation of hyperbolic tangent function in tanh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypCotangent()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / tanh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric sine function.
|
||||
*
|
||||
* See implementation of sine function in sin(double)
|
||||
*/
|
||||
Number* IntegerNumber::Sine()
|
||||
{
|
||||
return new RealNumber(sin(static_cast<double>(i)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Trigonometric cosecant function.
|
||||
*
|
||||
* See implementation of sine function in sin(double)
|
||||
*/
|
||||
Number* IntegerNumber::Cosecant()
|
||||
{
|
||||
double a = sin(static_cast<double>(i));
|
||||
|
||||
if (a == 0.0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(1.0 / a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric cosine function.
|
||||
*
|
||||
* See implementation of inverse trigonometric cosine in acos(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcCosine()
|
||||
{
|
||||
return new RealNumber(acos(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric secant function.
|
||||
*
|
||||
* See implementation of inverse trigonometric cosine in acos(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcSecant()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(acos(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric tangent function.
|
||||
*
|
||||
* See implementation of inverse trigonometric tangent in atan(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcTangent()
|
||||
{
|
||||
return new RealNumber(atan(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric cotangent function.
|
||||
*
|
||||
* See implementation of inverse trigonometric tangent in atan(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcCotangent()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(atan(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric sine function.
|
||||
*
|
||||
* See implementation of inverse trigonometric sine in asin(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcSine()
|
||||
{
|
||||
return new RealNumber(asin(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse trigonometric cosecant function.
|
||||
*
|
||||
* See implementation of inverse trigonometric sine in asin(double)
|
||||
*/
|
||||
Number* IntegerNumber::ArcCosecant()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(asin(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cosine function.
|
||||
*
|
||||
* See implementation of inverse hyperbolic cosine in acosh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcCosine()
|
||||
{
|
||||
return new RealNumber(acosh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic secant function.
|
||||
*
|
||||
* See implementation of inverse hyperbolic cosine in acosh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcSecant()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(acosh(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic sine function.
|
||||
*
|
||||
* See implementation of inverse hyperbolic sine in asinh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcSine()
|
||||
{
|
||||
return new RealNumber(asinh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cosecant function.
|
||||
*
|
||||
* See implementation of inverse hyperbolic sine in asinh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcCosecant()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(asinh(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic tangent function.
|
||||
*
|
||||
* See implementation hyperbolic tangent in atanh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcTangent()
|
||||
{
|
||||
return new RealNumber(atanh(static_cast<double>(i)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inverse hyperbolic cotangent function.
|
||||
*
|
||||
* See implementation hyperbolic tangent in atanh(double)
|
||||
*/
|
||||
Number* IntegerNumber::HypArcCotangent()
|
||||
{
|
||||
if (i == 0)
|
||||
return new NonNumber(nnnan);
|
||||
|
||||
return new RealNumber(atanh(1.0 / static_cast<double>(i)));
|
||||
}
|
||||
|
||||
Number* IntegerNumber::VerSine()
|
||||
{
|
||||
return new RealNumber(1.0 - cos((double)i), true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::VerCosine()
|
||||
{
|
||||
return new RealNumber(1.0 + cos((double)i), true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::CoVerSine()
|
||||
{
|
||||
return new RealNumber(1.0 - sin((double)i), true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::CoVerCosine()
|
||||
{
|
||||
return new RealNumber(1.0 + sin((double)i), true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::HaVerSine()
|
||||
{
|
||||
return new RealNumber((1.0 - cos((double)i)) / 2.0, true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::HaVerCosine()
|
||||
{
|
||||
return new RealNumber((1.0 + cos((double)i)) / 2.0, true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::HaCoVerSine()
|
||||
{
|
||||
return new RealNumber((1.0 - sin((double)i)) / 2.0, true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::HaCoVerCosine()
|
||||
{
|
||||
return new RealNumber((1.0 + sin((double)i)) / 2.0, true);
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcVerSine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcVerSine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcVerCosine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcVerCosine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcCoVerSine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcCoVerSine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcCoVerCosine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcCoVerCosine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcHaVerSine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcHaVerSine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcHaVerCosine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcHaVerCosine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcHaCoVerSine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcHaCoVerSine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcHaCoVerCosine()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcHaCoVerCosine();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ExSecant()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ExSecant();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ExCosecant()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ExCosecant();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcExSecant()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcExSecant();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
|
||||
Number* IntegerNumber::ArcExCosecant()
|
||||
{
|
||||
Number* n = new RealNumber(static_cast<double>(i));
|
||||
Number* x = n->ArcExCosecant();
|
||||
delete n;
|
||||
return x;
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AMATH_INTEGER_NUMBER_H
|
||||
#define AMATH_INTEGER_NUMBER_H
|
||||
|
||||
/**
|
||||
* @file integer.h
|
||||
* @brief Class based handling of integer numbers.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "numb.h"
|
||||
|
||||
#define MAX_INT_NUM 0x7fffffff
|
||||
|
||||
/**
|
||||
* @brief Represent a integer number.
|
||||
*
|
||||
*/
|
||||
struct IntegerNumber : public Number
|
||||
{
|
||||
public:
|
||||
IntegerNumber();
|
||||
explicit IntegerNumber(signed int i);
|
||||
explicit IntegerNumber(unsigned int i);
|
||||
~IntegerNumber();
|
||||
|
||||
Number* Clone();
|
||||
int GetIntegerValue();
|
||||
double GetRealValue();
|
||||
bool PureComplexValue();
|
||||
int GetPrecedence();
|
||||
int GetDefaultPrecedence();
|
||||
bool IsZero();
|
||||
bool IsNaN();
|
||||
bool IsTooSmall();
|
||||
bool IsTooLarge();
|
||||
bool IsNotImplemented();
|
||||
|
||||
Number* Unary();
|
||||
Number* Add(Number* other);
|
||||
Number* Sub(Number* other);
|
||||
Number* Mul(Number* other);
|
||||
Number* Div(Number* other);
|
||||
Number* Raise(Number* exponent);
|
||||
|
||||
Number* Signum();
|
||||
Number* Trunc();
|
||||
Number* Round();
|
||||
Number* Floor();
|
||||
Number* Ceiling();
|
||||
Number* Absolute();
|
||||
Number* SquareRoot();
|
||||
Number* CubeRoot();
|
||||
Number* Reciprocal();
|
||||
Number* Factorial();
|
||||
|
||||
Number* Log();
|
||||
Number* Log2();
|
||||
Number* Log10();
|
||||
|
||||
Number* Sine();
|
||||
Number* Cosine();
|
||||
Number* Tangent();
|
||||
Number* Cosecant();
|
||||
Number* Secant();
|
||||
Number* Cotangent();
|
||||
Number* ArcSine();
|
||||
Number* ArcCosine();
|
||||
Number* ArcTangent();
|
||||
Number* ArcCosecant();
|
||||
Number* ArcSecant();
|
||||
Number* ArcCotangent();
|
||||
|
||||
Number* HypSine();
|
||||
Number* HypCosine();
|
||||
Number* HypTangent();
|
||||
Number* HypCosecant();
|
||||
Number* HypSecant();
|
||||
Number* HypCotangent();
|
||||
Number* HypArcSine();
|
||||
Number* HypArcCosine();
|
||||
Number* HypArcTangent();
|
||||
Number* HypArcCosecant();
|
||||
Number* HypArcSecant();
|
||||
Number* HypArcCotangent();
|
||||
|
||||
Number* VerSine();
|
||||
Number* VerCosine();
|
||||
Number* CoVerSine();
|
||||
Number* CoVerCosine();
|
||||
Number* HaVerSine();
|
||||
Number* HaVerCosine();
|
||||
Number* HaCoVerSine();
|
||||
Number* HaCoVerCosine();
|
||||
|
||||
Number* ArcVerSine();
|
||||
Number* ArcVerCosine();
|
||||
Number* ArcCoVerSine();
|
||||
Number* ArcCoVerCosine();
|
||||
Number* ArcHaVerSine();
|
||||
Number* ArcHaVerCosine();
|
||||
Number* ArcHaCoVerSine();
|
||||
Number* ArcHaCoVerCosine();
|
||||
|
||||
Number* ExSecant();
|
||||
Number* ExCosecant();
|
||||
Number* ArcExSecant();
|
||||
Number* ArcExCosecant();
|
||||
|
||||
friend struct RealNumber;
|
||||
friend struct ComplexNumber;
|
||||
|
||||
private:
|
||||
signed int i;
|
||||
};
|
||||
|
||||
#endif
|
||||
+21
-11
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -70,26 +70,26 @@ int NonNumber::GetDefaultPrecedence()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool NonNumber::IsNegative()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NonNumber::IsZero()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NonNumber::IsTooSmall()
|
||||
{
|
||||
return type == nnninf;
|
||||
}
|
||||
|
||||
bool NonNumber::IsTooLarge()
|
||||
{
|
||||
return type == nninf;
|
||||
}
|
||||
|
||||
bool NonNumber::IsNaN()
|
||||
{
|
||||
return type == nnnan;
|
||||
}
|
||||
|
||||
bool NonNumber::IsInfinite()
|
||||
{
|
||||
return type == nnninf;
|
||||
}
|
||||
|
||||
bool NonNumber::IsNotImplemented()
|
||||
{
|
||||
return type == nnnimp;
|
||||
@@ -219,6 +219,11 @@ Number* NonNumber::Cotangent()
|
||||
return new NonNumber(type);
|
||||
}
|
||||
|
||||
Number *NonNumber::Chord()
|
||||
{
|
||||
return new NonNumber(type);
|
||||
}
|
||||
|
||||
Number* NonNumber::HypSine()
|
||||
{
|
||||
return new NonNumber(type);
|
||||
@@ -289,6 +294,11 @@ Number* NonNumber::ArcCosecant()
|
||||
return new NonNumber(type);
|
||||
}
|
||||
|
||||
Number *NonNumber::ArcChord()
|
||||
{
|
||||
return new NonNumber(type);
|
||||
}
|
||||
|
||||
Number* NonNumber::HypArcCosine()
|
||||
{
|
||||
return new NonNumber(type);
|
||||
|
||||
+11
-12
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
|
||||
/**
|
||||
* @file nnumb.h
|
||||
* @brief Class based handling of Infinity and Not A Number.
|
||||
*
|
||||
* @brief Class based handling of Infinity and Not A Number
|
||||
*/
|
||||
|
||||
#include "numb.h"
|
||||
@@ -47,8 +46,7 @@ typedef enum
|
||||
} NonNumberType;
|
||||
|
||||
/**
|
||||
* @brief Represent a number which does not exists.
|
||||
*
|
||||
* @brief Represent a number which does not exists
|
||||
*/
|
||||
struct NonNumber : public Number
|
||||
{
|
||||
@@ -62,10 +60,10 @@ public:
|
||||
bool PureComplexValue();
|
||||
int GetPrecedence();
|
||||
int GetDefaultPrecedence();
|
||||
bool IsNegative();
|
||||
bool IsZero();
|
||||
bool IsNaN();
|
||||
bool IsTooSmall();
|
||||
bool IsTooLarge();
|
||||
bool IsInfinite();
|
||||
bool IsNotImplemented();
|
||||
|
||||
Number* Unary();
|
||||
@@ -96,12 +94,18 @@ public:
|
||||
Number* Cosecant();
|
||||
Number* Secant();
|
||||
Number* Cotangent();
|
||||
Number* Chord();
|
||||
Number* ExSecant();
|
||||
Number* ExCosecant();
|
||||
Number* ArcSine();
|
||||
Number* ArcCosine();
|
||||
Number* ArcTangent();
|
||||
Number* ArcCosecant();
|
||||
Number* ArcSecant();
|
||||
Number* ArcCotangent();
|
||||
Number* ArcExSecant();
|
||||
Number* ArcExCosecant();
|
||||
Number* ArcChord();
|
||||
|
||||
Number* HypSine();
|
||||
Number* HypCosine();
|
||||
@@ -134,11 +138,6 @@ public:
|
||||
Number* ArcHaCoVerSine();
|
||||
Number* ArcHaCoVerCosine();
|
||||
|
||||
Number* ExSecant();
|
||||
Number* ExCosecant();
|
||||
Number* ArcExSecant();
|
||||
Number* ArcExCosecant();
|
||||
|
||||
private:
|
||||
NonNumberType type;
|
||||
};
|
||||
|
||||
+3
-423
@@ -23,22 +23,13 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "amath.h"
|
||||
#include "amathc.h"
|
||||
#include "math.h"
|
||||
#include "complex.h"
|
||||
#include "real.h"
|
||||
#include "cplex.h"
|
||||
#include "ntext.h"
|
||||
#include "integer.h"
|
||||
#include "charbuf.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
NumeralSystem::NumeralSystem()
|
||||
{
|
||||
buf = new CharBuffer();
|
||||
@@ -50,420 +41,9 @@ NumeralSystem::~NumeralSystem()
|
||||
delete buf;
|
||||
}
|
||||
|
||||
Number* NumeralSystem::Parse(const char* text)
|
||||
Number *NumeralSystem::Parse(const char *text)
|
||||
{
|
||||
unsigned int length;
|
||||
char* end;
|
||||
char *end;
|
||||
return Parse(text, &length, &end);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PositionalNumeralSystem::PositionalNumeralSystem(
|
||||
unsigned int base,
|
||||
unsigned int digits,
|
||||
const char fractionpoint) :
|
||||
base(base * 1.0), digits(digits)
|
||||
{
|
||||
this->fractionpoint = fractionpoint;
|
||||
}
|
||||
|
||||
PositionalNumeralSystem::~PositionalNumeralSystem()
|
||||
{
|
||||
}
|
||||
|
||||
const char* PositionalNumeralSystem::GetName()
|
||||
{
|
||||
switch (static_cast<int>(base))
|
||||
{
|
||||
case 2:
|
||||
return "binary";
|
||||
case 8:
|
||||
return "octal";
|
||||
case 10:
|
||||
return "decimal";
|
||||
case 16:
|
||||
return "hexadecimal";
|
||||
}
|
||||
|
||||
const char* text = "base ";
|
||||
Number* n = new RealNumber(base);
|
||||
NumeralSystem* ns = new DecimalSystem(2);
|
||||
const char* numtext = ns->GetText(n);
|
||||
|
||||
buf->EnsureSize(StrLen(text) + StrLen(numtext) + 1);
|
||||
buf->Empty();
|
||||
buf->Append(text);
|
||||
buf->Append(numtext);
|
||||
|
||||
delete ns;
|
||||
delete n;
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
const char* PositionalNumeralSystem::GetPrefix()
|
||||
{
|
||||
// TODO: Implement
|
||||
return "";
|
||||
}
|
||||
|
||||
unsigned int PositionalNumeralSystem::GetDigits()
|
||||
{
|
||||
return digits;
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::SetDigits(unsigned int digits)
|
||||
{
|
||||
this->digits = digits;
|
||||
}
|
||||
|
||||
const char PositionalNumeralSystem::GetFractionPoint()
|
||||
{
|
||||
return static_cast<const char>(this->fractionpoint);
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::SetFractionPoint(const char fractionpoint)
|
||||
{
|
||||
this->fractionpoint = fractionpoint;
|
||||
}
|
||||
|
||||
const char* PositionalNumeralSystem::GetText(Number* number)
|
||||
{
|
||||
if (number->IsNaN())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("NaN");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsNotImplemented())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("NotImplemented");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsTooSmall())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("-Inf");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsTooLarge())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("Inf");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->system == nsysinteger)
|
||||
{
|
||||
return GetText(number->GetRealValue()); // TODO: Optimize
|
||||
}
|
||||
|
||||
if (number->system == nsysreal)
|
||||
{
|
||||
return GetText(number->GetRealValue());
|
||||
}
|
||||
|
||||
complex w = static_cast<ComplexNumber*>(number)->GetComplexValue();
|
||||
double a = creal(w);
|
||||
double b = cimag(w);
|
||||
|
||||
if (a == 0.0 && b == 0.0)
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append('0');
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
CharBuffer* val = new CharBuffer(512);
|
||||
val->Empty();
|
||||
|
||||
if (a != 0.0)
|
||||
{
|
||||
const char* real = GetText(a);
|
||||
val->Append(real);
|
||||
}
|
||||
|
||||
const char* imag = GetText(b);
|
||||
if (a != 0.0 && b > 0.0)
|
||||
{
|
||||
val->Append('+');
|
||||
}
|
||||
|
||||
if (b != 0.0)
|
||||
{
|
||||
val->Append(imag);
|
||||
val->Append('i');
|
||||
}
|
||||
|
||||
buf->Copy(val);
|
||||
delete val;
|
||||
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
const char* PositionalNumeralSystem::GetText(double number) const
|
||||
{
|
||||
if (!finite(number))
|
||||
{
|
||||
return "Inf";
|
||||
}
|
||||
else if (isnan(number))
|
||||
{
|
||||
return "NaN";
|
||||
}
|
||||
else if (number == 0.0)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
|
||||
buf->Empty();
|
||||
|
||||
double dnumber = number;
|
||||
if (dnumber < 0.0)
|
||||
{
|
||||
buf->Append('-');
|
||||
dnumber = -dnumber;
|
||||
}
|
||||
|
||||
double expbor = log2p(base, dnumber);
|
||||
double expacc = expbor > 0.0 ? 4e-14 : -1e-15;
|
||||
double expborder = trunc(expbor + expacc);
|
||||
|
||||
int exponent = 0;
|
||||
double rounding;
|
||||
|
||||
double bordermax = trunc(9.0 * 10 / base);
|
||||
double bordermin = trunc(-8.0 * 10 / base);
|
||||
|
||||
// Find exponent
|
||||
if (expborder >= bordermax || expborder <= bordermin)
|
||||
{
|
||||
double dexp = trunc(log2p(base, dnumber) + expacc);
|
||||
dnumber = dnumber * pow(base, -dexp);
|
||||
|
||||
// pow is inaccurate on small and large numbers
|
||||
if (dexp > 15 || dexp < -15)
|
||||
{
|
||||
dnumber += 2e-15;
|
||||
}
|
||||
|
||||
// Adjust if below zero
|
||||
if (dnumber < 1.0)
|
||||
{
|
||||
dexp--;
|
||||
dnumber *= base;
|
||||
}
|
||||
|
||||
exponent = static_cast<int>(dexp);
|
||||
rounding = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double acc = exponent > 0 ? 15 : -15;
|
||||
rounding = pow(base, exponent + acc);
|
||||
}
|
||||
|
||||
int digitout;
|
||||
int intdigits;
|
||||
|
||||
double intvalue = trunc(dnumber + rounding);
|
||||
IntegerToBuffer(intvalue, digits, &intdigits);
|
||||
|
||||
int fragdigits = digits - intdigits + (intvalue < 1.0 ? 1 : 0);
|
||||
if (fragdigits > 0)
|
||||
{
|
||||
buf->Append(fractionpoint);
|
||||
|
||||
double fraction = fabs(round((dnumber - intvalue) * pow(base, fragdigits)));
|
||||
|
||||
double temp1 = log2p(base, fraction);
|
||||
int fin = finite(temp1);
|
||||
int actualdigits = static_cast<int>(trunc(temp1 + 3e-15));
|
||||
int padding = fragdigits - (fin == 1 ? actualdigits : 0) - 1;
|
||||
|
||||
// Pad zeros if needed
|
||||
while (padding-- > 0)
|
||||
{
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
intvalue = static_cast<int64_t>(trunc(fraction * base) / base);
|
||||
IntegerToBuffer(intvalue, fragdigits, &digitout);
|
||||
|
||||
// Remove trailing zeros
|
||||
// ReSharper disable once CppPossiblyErroneousEmptyStatements
|
||||
while (buf->RemoveTrailing('0'));
|
||||
|
||||
buf->RemoveTrailing(fractionpoint);
|
||||
}
|
||||
|
||||
// Add exponent
|
||||
if (exponent != 0)
|
||||
{
|
||||
buf->Append('e');
|
||||
buf->Append(exponent > 0 ? '+' : '-');
|
||||
IntegerToBuffer(abs(exponent), 3, &digitout);
|
||||
}
|
||||
|
||||
// Make sure no rounding error is returned
|
||||
if (buf->Is("-0"))
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::IntegerToBuffer(double value, unsigned int digits, int* outdigits) const
|
||||
{
|
||||
static const char* alphaNumerics = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
unsigned int count = 0;
|
||||
char* chars = new char[128];
|
||||
char* start = chars;
|
||||
|
||||
do
|
||||
{
|
||||
count++;
|
||||
unsigned int intremainder = static_cast<unsigned int>(trunc(fmod(value, base)));
|
||||
*chars++ = alphaNumerics[intremainder];
|
||||
value /= base;
|
||||
}
|
||||
while (value >= 1.0);
|
||||
|
||||
unsigned int n = count;
|
||||
unsigned int q = digits;
|
||||
chars--;
|
||||
|
||||
while (n-- != 0 && q-- != 0)
|
||||
{
|
||||
buf->Append(*chars--);
|
||||
}
|
||||
|
||||
n++;
|
||||
while (n-- != 0)
|
||||
{
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
*outdigits = count;
|
||||
delete [] start;
|
||||
}
|
||||
|
||||
Number* PositionalNumeralSystem::Parse(const char* text, unsigned int* length, char** end)
|
||||
{
|
||||
unsigned int intbase = static_cast<unsigned int>(base);
|
||||
char maxNumeric = (intbase > 10 ? 10 : intbase) + '0' - 1;
|
||||
char maxAlpha = intbase > 10 ? intbase + 'A' - 11 : 0;
|
||||
|
||||
unsigned int pos = 0;
|
||||
double integer = 0;
|
||||
double addition;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != 0 && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10)) * 1.0;
|
||||
integer = integer * base + addition;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
// Digits not found
|
||||
if (pos == 0)
|
||||
{
|
||||
*length = 0;
|
||||
*end = const_cast<char*>(text);
|
||||
return new RealNumber();
|
||||
}
|
||||
|
||||
double fraction = 0.0;
|
||||
double divisor = 1.0;
|
||||
if (*text == fractionpoint && fractionpoint != '\0')
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != '\0' && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10));
|
||||
fraction = fraction * base + addition;
|
||||
divisor *= base;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
double exp = 0.0;
|
||||
if (*text == 'e' || *text == 'E')
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
double sign = *text == '+' ? 1.0 : *text == '-' ? -1.0 : 0.0;
|
||||
|
||||
if (sign != 0.0)
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != 0 && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10)) * 1.0;
|
||||
exp = exp * base + addition;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
exp *= sign;
|
||||
}
|
||||
else
|
||||
{
|
||||
text--;
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
*length = pos;
|
||||
*end = const_cast<char*>(text);
|
||||
|
||||
if (integer >= static_cast<double>(MAX_INT_NUM) && fraction == 0.0 && exp == 0.0)
|
||||
return new IntegerNumber(static_cast<int>(integer));
|
||||
|
||||
|
||||
double dnumber = (integer + (fraction / divisor));
|
||||
|
||||
if (exp != 0.0)
|
||||
{
|
||||
// pow seems a bit off
|
||||
dnumber *= pow(base, exp + 4e-15);
|
||||
}
|
||||
|
||||
return new RealNumber(dnumber);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
DecimalSystem::DecimalSystem() :
|
||||
PositionalNumeralSystem(10, 5, '\0')
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::DecimalSystem(unsigned int digits) :
|
||||
PositionalNumeralSystem(10, digits, '\0')
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::DecimalSystem(
|
||||
unsigned int digits,
|
||||
const char fractionpoint) :
|
||||
PositionalNumeralSystem(10, digits, fractionpoint)
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::~DecimalSystem()
|
||||
{
|
||||
}
|
||||
|
||||
+5
-49
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -32,21 +32,19 @@
|
||||
|
||||
/**
|
||||
* @file ntext.h
|
||||
* @brief Text to numbers handling.
|
||||
* @brief Text to numbers handling
|
||||
* @details
|
||||
* Converts both between text and numbers AND between numbers and text.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "numb.h"
|
||||
#include "charbuf.h"
|
||||
|
||||
/**
|
||||
* @brief Base class for all numeral systems.
|
||||
* @brief Base class for all numeral systems
|
||||
* @details
|
||||
* More info on numeral systems is available at [Wikipedia]:
|
||||
* More info on numeral systems is available at Wikipedia:
|
||||
* https://wikipedia.org/wiki/Numeral_system
|
||||
*
|
||||
*/
|
||||
class NumeralSystem
|
||||
{
|
||||
@@ -58,7 +56,7 @@ public:
|
||||
virtual unsigned int GetDigits() = 0;
|
||||
virtual void SetDigits(unsigned int digits) = 0;
|
||||
virtual const char GetFractionPoint() = 0;
|
||||
virtual void SetFractionPoint(const char fractionpoint) = 0;
|
||||
virtual void SetFractionPoint(const char fractionPoint) = 0;
|
||||
virtual const char* GetText(Number* number) = 0;
|
||||
virtual Number* Parse(const char* text, unsigned int* length, char** end) = 0;
|
||||
virtual Number* Parse(const char* text);
|
||||
@@ -67,46 +65,4 @@ protected:
|
||||
CharBuffer* buf;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Base class for all numeral systems with a
|
||||
* positional notation.
|
||||
* @details
|
||||
* More info on positional notation is available at [Wikipedia]:
|
||||
* https://wikipedia.org/wiki/Positional_notation
|
||||
*
|
||||
*/
|
||||
class PositionalNumeralSystem : public NumeralSystem
|
||||
{
|
||||
public:
|
||||
PositionalNumeralSystem(unsigned int base, unsigned int digits, const char fractionpoint);
|
||||
~PositionalNumeralSystem();
|
||||
|
||||
virtual const char* GetName();
|
||||
virtual const char* GetPrefix();
|
||||
virtual unsigned int GetDigits();
|
||||
virtual void SetDigits(unsigned int digits);
|
||||
virtual const char GetFractionPoint();
|
||||
virtual void SetFractionPoint(const char fractionpoint);
|
||||
virtual const char* GetText(Number* number);
|
||||
virtual Number* Parse(const char* text, unsigned int* length, char** end);
|
||||
|
||||
protected:
|
||||
double base;
|
||||
unsigned int digits;
|
||||
char fractionpoint;
|
||||
|
||||
private:
|
||||
const char* GetText(double number) const;
|
||||
void IntegerToBuffer(double value, unsigned int digits, int* outdigits) const;
|
||||
};
|
||||
|
||||
class DecimalSystem : public PositionalNumeralSystem
|
||||
{
|
||||
public:
|
||||
DecimalSystem();
|
||||
DecimalSystem(unsigned int digits, const char fractionpoint);
|
||||
explicit DecimalSystem(unsigned int digits);
|
||||
~DecimalSystem();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014 Ryan Juckett
|
||||
* http://www.ryanjuckett.com/
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not
|
||||
* be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
|
||||
#include "ntextd.h"
|
||||
#include "bigint.h"
|
||||
#include "amathc.h"
|
||||
#include "amath.h"
|
||||
#include "mathr.h"
|
||||
#include "mathi.h"
|
||||
#include "cplex.h"
|
||||
|
||||
DecimalSystem::DecimalSystem() : PositionalNumeralSystem(10, 5, '\0')
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::DecimalSystem(unsigned int digits) :
|
||||
PositionalNumeralSystem(10, digits, '\0')
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::DecimalSystem(unsigned int digits, const char fractionPoint) :
|
||||
PositionalNumeralSystem(10, digits, fractionPoint)
|
||||
{
|
||||
}
|
||||
|
||||
DecimalSystem::~DecimalSystem()
|
||||
{
|
||||
}
|
||||
|
||||
const char *DecimalSystem::GetText(Number *number)
|
||||
{
|
||||
const char *sc = GetSpecialCase(number);
|
||||
if (sc != nullptr)
|
||||
{
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (number->system == nsysreal)
|
||||
{
|
||||
buf->Empty();
|
||||
return GetText(number->GetRealValue());
|
||||
}
|
||||
|
||||
complex w = ((ComplexNumber *)number)->GetComplexValue();
|
||||
double a = creal(w);
|
||||
double b = cimag(w);
|
||||
|
||||
buf->Empty();
|
||||
if (a != 0.0)
|
||||
{
|
||||
GetText(a);
|
||||
}
|
||||
|
||||
if (a != 0.0 && b > 0.0)
|
||||
{
|
||||
buf->Append('+');
|
||||
}
|
||||
|
||||
if (b != 0.0)
|
||||
{
|
||||
GetText(b);
|
||||
buf->Append('i');
|
||||
}
|
||||
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
const char *DecimalSystem::GetText(double number) const
|
||||
{
|
||||
int32_t printExponent = 0;
|
||||
double dexponent = log10(fabs(number));
|
||||
int32_t precision = digits - (int32_t)trunc(dexponent) - 1;
|
||||
int32_t lim = 15;
|
||||
bool sci = (dexponent > 9.0 || dexponent < -8.0);
|
||||
if (sci)
|
||||
{
|
||||
precision = digits;
|
||||
}
|
||||
else if (dexponent < 0.0)
|
||||
{
|
||||
precision++;
|
||||
lim--;
|
||||
}
|
||||
|
||||
if (precision > lim)
|
||||
{
|
||||
precision = lim;
|
||||
}
|
||||
|
||||
static const int size = 64;
|
||||
char *out = new char[size];
|
||||
char *pOutBuffer = out;
|
||||
uint32_t bufferSize = size;
|
||||
|
||||
FloatUnion64 floatUnion;
|
||||
floatUnion.floatingPoint = number;
|
||||
uint32_t floatExponent = floatUnion.GetExponent();
|
||||
uint64_t floatMantissa = floatUnion.GetMantissa();
|
||||
|
||||
if (floatUnion.IsNegative())
|
||||
{
|
||||
pOutBuffer[0] = '-';
|
||||
++pOutBuffer;
|
||||
--bufferSize;
|
||||
}
|
||||
|
||||
uint64_t mantissa;
|
||||
int32_t exponent;
|
||||
uint32_t mantissaHighBitIdx;
|
||||
bool hasUnequalMargins;
|
||||
|
||||
if (floatExponent != 0)
|
||||
{
|
||||
// normal
|
||||
mantissa = (1ull << 52) | floatMantissa;
|
||||
exponent = floatExponent - 1023 - 52;
|
||||
mantissaHighBitIdx = 52;
|
||||
hasUnequalMargins = (floatExponent != 1) && (floatMantissa == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// subnormal
|
||||
mantissa = floatMantissa;
|
||||
exponent = 1 - 1023 - 52;
|
||||
mantissaHighBitIdx = log2i(mantissa);
|
||||
hasUnequalMargins = false;
|
||||
}
|
||||
|
||||
if (!sci)
|
||||
{
|
||||
int32_t printExponent;
|
||||
uint32_t numPrintDigits;
|
||||
uint32_t maxPrintLen = bufferSize - 1;
|
||||
numPrintDigits = Dragon4(mantissa,
|
||||
exponent,
|
||||
mantissaHighBitIdx,
|
||||
hasUnequalMargins,
|
||||
CutoffMode_FractionLength,
|
||||
precision,
|
||||
pOutBuffer,
|
||||
maxPrintLen,
|
||||
&printExponent);
|
||||
|
||||
// track the number of digits past the decimal point that have been printed
|
||||
uint32_t numFractionDigits = 0;
|
||||
|
||||
// if output has a whole number
|
||||
if (printExponent >= 0)
|
||||
{
|
||||
// leave the whole number at the start of the buffer
|
||||
uint32_t numWholeDigits = printExponent + 1;
|
||||
if (numPrintDigits < numWholeDigits)
|
||||
{
|
||||
// don't overflow the buffer
|
||||
if (numWholeDigits > maxPrintLen)
|
||||
numWholeDigits = maxPrintLen;
|
||||
|
||||
// add trailing zeros up to the decimal point
|
||||
for (; numPrintDigits < numWholeDigits; ++numPrintDigits)
|
||||
pOutBuffer[numPrintDigits] = '0';
|
||||
}
|
||||
// insert the decimal point prior to the fraction
|
||||
else if (numPrintDigits > (uint32_t)numWholeDigits)
|
||||
{
|
||||
numFractionDigits = numPrintDigits - numWholeDigits;
|
||||
uint32_t maxFractionDigits = maxPrintLen - numWholeDigits - 1;
|
||||
if (numFractionDigits > maxFractionDigits)
|
||||
numFractionDigits = maxFractionDigits;
|
||||
|
||||
MemCopy(pOutBuffer + numWholeDigits + 1, pOutBuffer + numWholeDigits, numFractionDigits);
|
||||
pOutBuffer[numWholeDigits] = fractionPoint;
|
||||
numPrintDigits = numWholeDigits + 1 + numFractionDigits;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// shift out the fraction to make room for the leading zeros
|
||||
if (maxPrintLen > 2)
|
||||
{
|
||||
uint32_t numFractionZeros = (uint32_t)-printExponent - 1;
|
||||
uint32_t maxFractionZeros = maxPrintLen - 2;
|
||||
if (numFractionZeros > maxFractionZeros)
|
||||
numFractionZeros = maxFractionZeros;
|
||||
|
||||
uint32_t digitsStartIdx = 2 + numFractionZeros;
|
||||
|
||||
// shift the significant digits right such that there is room for leading zeros
|
||||
numFractionDigits = numPrintDigits;
|
||||
uint32_t maxFractionDigits = maxPrintLen - digitsStartIdx;
|
||||
if (numFractionDigits > maxFractionDigits)
|
||||
numFractionDigits = maxFractionDigits;
|
||||
|
||||
MemCopy(pOutBuffer + digitsStartIdx, pOutBuffer, numFractionDigits);
|
||||
|
||||
// insert the leading zeros
|
||||
for (uint32_t i = 2; i < digitsStartIdx; ++i)
|
||||
pOutBuffer[i] = '0';
|
||||
|
||||
// update the counts
|
||||
numFractionDigits += numFractionZeros;
|
||||
numPrintDigits = numFractionDigits;
|
||||
}
|
||||
|
||||
// add the decimal point
|
||||
if (maxPrintLen > 1)
|
||||
{
|
||||
pOutBuffer[1] = fractionPoint;
|
||||
numPrintDigits += 1;
|
||||
}
|
||||
|
||||
// add the initial zero
|
||||
if (maxPrintLen > 0)
|
||||
{
|
||||
pOutBuffer[0] = '0';
|
||||
numPrintDigits += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// add trailing zeros up to precision length
|
||||
if (precision > (int32_t)numFractionDigits && numPrintDigits < maxPrintLen)
|
||||
{
|
||||
// add a decimal point if this is the first fractional digit we are printing
|
||||
if (numFractionDigits == 0)
|
||||
{
|
||||
pOutBuffer[numPrintDigits++] = fractionPoint;
|
||||
}
|
||||
|
||||
// compute the number of trailing zeros needed
|
||||
uint32_t totalDigits = numPrintDigits + (precision - numFractionDigits);
|
||||
if (totalDigits > maxPrintLen)
|
||||
totalDigits = maxPrintLen;
|
||||
|
||||
for (; numPrintDigits < totalDigits; ++numPrintDigits)
|
||||
pOutBuffer[numPrintDigits] = '0';
|
||||
}
|
||||
|
||||
pOutBuffer[numPrintDigits] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t numPrintDigits;
|
||||
numPrintDigits = Dragon4(mantissa,
|
||||
exponent,
|
||||
mantissaHighBitIdx,
|
||||
hasUnequalMargins,
|
||||
CutoffMode_TotalLength,
|
||||
precision + 1,
|
||||
pOutBuffer,
|
||||
bufferSize,
|
||||
&printExponent);
|
||||
|
||||
char *pCurOut = pOutBuffer;
|
||||
pCurOut += 1;
|
||||
|
||||
// insert the decimal point prior to the fractional number
|
||||
uint32_t numFractionDigits = numPrintDigits - 1;
|
||||
if (numFractionDigits > 0 && bufferSize > 1)
|
||||
{
|
||||
uint32_t maxFractionDigits = bufferSize - 2;
|
||||
if (numFractionDigits > maxFractionDigits)
|
||||
numFractionDigits = maxFractionDigits;
|
||||
|
||||
MemCopy(pCurOut + 1, pCurOut, numFractionDigits);
|
||||
pCurOut[0] = fractionPoint;
|
||||
pCurOut += (1 + numFractionDigits);
|
||||
}
|
||||
|
||||
pCurOut[0] = '\0';
|
||||
}
|
||||
|
||||
buf->EnsureGrowth(size);
|
||||
buf->Append(out);
|
||||
|
||||
if (fractionPoint != '\0' && buf->Contains(fractionPoint))
|
||||
{
|
||||
while (buf->RemoveTrailing('0'))
|
||||
;
|
||||
buf->RemoveTrailing(fractionPoint);
|
||||
}
|
||||
|
||||
if (printExponent != 0)
|
||||
{
|
||||
buf->Append('e');
|
||||
if (printExponent >= 0)
|
||||
{
|
||||
buf->Append('+');
|
||||
}
|
||||
else
|
||||
{
|
||||
buf->Append('-');
|
||||
printExponent = -printExponent;
|
||||
}
|
||||
int temp;
|
||||
IntegerToBuffer(printExponent, 3, &temp);
|
||||
}
|
||||
|
||||
if (fractionPoint != '\0' && buf->Contains(fractionPoint) && !buf->Contains('e'))
|
||||
{
|
||||
while (buf->RemoveTrailing('0'))
|
||||
;
|
||||
buf->RemoveTrailing(fractionPoint);
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
return buf->GetString();
|
||||
}
|
||||
@@ -23,29 +23,26 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AMATH_LOCALIZE_TAGS_H
|
||||
#define AMATH_LOCALIZE_TAGS_H
|
||||
#ifndef AMATH_NUMERAL_DECIMAL_H
|
||||
#define AMATH_NUMERAL_DECIMAL_H
|
||||
|
||||
#include "amath.h"
|
||||
#include "amathc.h"
|
||||
#include "ntextp.h"
|
||||
|
||||
static const texttag texttags[] = {
|
||||
{"#HEADLINE#", HEADLINE},
|
||||
{"#SYNTAXHIGHLIGHT#", SYNTAXHIGHLIGHT},
|
||||
{"#NORMALTEXT#", NORMALTEXT},
|
||||
{"#BOLD#", BOLD},
|
||||
{"#ITALICS#", ITALICS},
|
||||
{"#UNDERLINE#", UNDERLINE},
|
||||
{"#COLOR01#", COLOR01},
|
||||
{"#COLOR02#", COLOR02},
|
||||
{"#COLOR03#", COLOR03},
|
||||
{"#SPACE#", SPACE},
|
||||
{"#NEWLINE#", NEWLINE},
|
||||
{"#STARTMSG#", TXTSTARTMSG}
|
||||
class DecimalSystem : public PositionalNumeralSystem
|
||||
{
|
||||
public:
|
||||
DecimalSystem();
|
||||
DecimalSystem(unsigned int digits);
|
||||
DecimalSystem(unsigned int digits, const char fractionPoint);
|
||||
~DecimalSystem();
|
||||
virtual const char *GetText(Number *number);
|
||||
|
||||
private:
|
||||
const char *GetText(double number) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,425 @@
|
||||
/*-
|
||||
* Copyright (c) 2014-2017 Carsten Sonne Larsen <cs@innolan.net>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#include "amath.h"
|
||||
#include "amathc.h"
|
||||
#include "mathr.h"
|
||||
#include "mathi.h"
|
||||
#include "real.h"
|
||||
#include "cplex.h"
|
||||
#include "ntext.h"
|
||||
#include "ntextd.h"
|
||||
#include "charbuf.h"
|
||||
|
||||
PositionalNumeralSystem::PositionalNumeralSystem(
|
||||
unsigned int base,
|
||||
unsigned int digits,
|
||||
const char fractionPoint) : base(base * 1.0), digits(digits)
|
||||
{
|
||||
this->fractionPoint = fractionPoint;
|
||||
}
|
||||
|
||||
PositionalNumeralSystem::~PositionalNumeralSystem()
|
||||
{
|
||||
}
|
||||
|
||||
const char *PositionalNumeralSystem::GetName()
|
||||
{
|
||||
switch (static_cast<int>(base))
|
||||
{
|
||||
case 2:
|
||||
return "binary";
|
||||
case 8:
|
||||
return "octal";
|
||||
case 10:
|
||||
return "decimal";
|
||||
case 16:
|
||||
return "hexadecimal";
|
||||
}
|
||||
|
||||
const char *text = "base ";
|
||||
Number *n = new RealNumber(base);
|
||||
NumeralSystem *ns = new DecimalSystem(2);
|
||||
const char *numtext = ns->GetText(n);
|
||||
|
||||
buf->EnsureSize(StrLen(text) + StrLen(numtext) + 1);
|
||||
buf->Empty();
|
||||
buf->Append(text);
|
||||
buf->Append(numtext);
|
||||
|
||||
delete ns;
|
||||
delete n;
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
const char *PositionalNumeralSystem::GetPrefix()
|
||||
{
|
||||
// TODO: Consider using prefix with numral systems != base 10
|
||||
return EMPTYSTRING;
|
||||
}
|
||||
|
||||
unsigned int PositionalNumeralSystem::GetDigits()
|
||||
{
|
||||
return digits;
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::SetDigits(unsigned int digits)
|
||||
{
|
||||
this->digits = digits;
|
||||
}
|
||||
|
||||
const char PositionalNumeralSystem::GetFractionPoint()
|
||||
{
|
||||
return static_cast<const char>(this->fractionPoint);
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::SetFractionPoint(const char fractionPoint)
|
||||
{
|
||||
this->fractionPoint = fractionPoint;
|
||||
}
|
||||
|
||||
const char *PositionalNumeralSystem::GetSpecialCase(Number *number)
|
||||
{
|
||||
if (number->IsNaN())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("NaN");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsNotImplemented())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("NotImplemented");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsInfinite() && number->IsNegative())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("-Inf");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsInfinite() && !number->IsNegative())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("Inf");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
if (number->IsZero())
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append("0");
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *PositionalNumeralSystem::GetText(Number *number)
|
||||
{
|
||||
const char *sc = GetSpecialCase(number);
|
||||
if (sc != nullptr)
|
||||
{
|
||||
return sc;
|
||||
}
|
||||
|
||||
if (number->system == nsysreal)
|
||||
{
|
||||
return GetText(number->GetRealValue());
|
||||
}
|
||||
|
||||
complex w = static_cast<ComplexNumber *>(number)->GetComplexValue();
|
||||
double a = creal(w);
|
||||
double b = cimag(w);
|
||||
|
||||
if (a == 0.0 && b == 0.0)
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append('0');
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
CharBuffer *val = new CharBuffer(512);
|
||||
val->Empty();
|
||||
|
||||
if (a != 0.0)
|
||||
{
|
||||
const char *real = GetText(a);
|
||||
val->Append(real);
|
||||
}
|
||||
|
||||
const char *imag = GetText(b);
|
||||
if (a != 0.0 && b > 0.0)
|
||||
{
|
||||
val->Append('+');
|
||||
}
|
||||
|
||||
if (b != 0.0)
|
||||
{
|
||||
val->Append(imag);
|
||||
val->Append('i');
|
||||
}
|
||||
|
||||
buf->Copy(val);
|
||||
delete val;
|
||||
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
const char *PositionalNumeralSystem::GetText(double number) const
|
||||
{
|
||||
if (number == 0.0)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
|
||||
buf->Empty();
|
||||
|
||||
double dnumber = number;
|
||||
if (dnumber < 0.0)
|
||||
{
|
||||
buf->Append('-');
|
||||
dnumber = -dnumber;
|
||||
}
|
||||
|
||||
double expbor = log2p(base, dnumber);
|
||||
double expacc = expbor > 0.0 ? 4e-14 : -1e-15;
|
||||
double expborder = trunc(expbor + expacc);
|
||||
|
||||
int exponent = 0;
|
||||
double rounding;
|
||||
|
||||
double bordermax = trunc(9.0 * 10 / base);
|
||||
double bordermin = trunc(-8.0 * 10 / base);
|
||||
|
||||
// Find exponent
|
||||
if (expborder >= bordermax || expborder <= bordermin)
|
||||
{
|
||||
double dexp = trunc(log2p(base, dnumber) + expacc);
|
||||
dnumber = dnumber * pow(base, -dexp);
|
||||
|
||||
// pow is inaccurate on small and large numbers
|
||||
if (dexp > 15 || dexp < -15)
|
||||
{
|
||||
dnumber += 2e-15;
|
||||
}
|
||||
|
||||
// Adjust if below zero
|
||||
if (dnumber < 1.0)
|
||||
{
|
||||
dexp--;
|
||||
dnumber *= base;
|
||||
}
|
||||
|
||||
exponent = static_cast<int>(dexp);
|
||||
rounding = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double acc = exponent > 0 ? 15 : -15;
|
||||
rounding = pow(base, exponent + acc);
|
||||
}
|
||||
|
||||
int digitout;
|
||||
int intdigits;
|
||||
|
||||
double intvalue = trunc(dnumber + rounding);
|
||||
IntegerToBuffer(intvalue, digits, &intdigits);
|
||||
|
||||
int fragdigits = digits - intdigits + (intvalue < 1.0 ? 1 : 0);
|
||||
if (fragdigits > 0)
|
||||
{
|
||||
buf->Append(fractionPoint);
|
||||
|
||||
double fraction = fabs(round((dnumber - intvalue) * pow(base, fragdigits)));
|
||||
double temp1 = log2p(base, fraction);
|
||||
FloatUnion64 temp2;
|
||||
temp2.floatingPoint = temp1;
|
||||
bool fin = !temp2.IsInf();
|
||||
int actualdigits = static_cast<int>(trunc(temp1 + 3e-15));
|
||||
int padding = fragdigits - (fin == 1 ? actualdigits : 0) - 1;
|
||||
|
||||
// Pad zeros if needed
|
||||
while (padding-- > 0)
|
||||
{
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
intvalue = static_cast<int64_t>(trunc(fraction * base) / base);
|
||||
IntegerToBuffer(intvalue, fragdigits, &digitout);
|
||||
|
||||
// Remove trailing zeros
|
||||
// ReSharper disable once CppPossiblyErroneousEmptyStatements
|
||||
while (buf->RemoveTrailing('0'))
|
||||
;
|
||||
|
||||
buf->RemoveTrailing(fractionPoint);
|
||||
}
|
||||
|
||||
// Add exponent
|
||||
if (exponent != 0)
|
||||
{
|
||||
buf->Append('e');
|
||||
buf->Append(exponent > 0 ? '+' : '-');
|
||||
IntegerToBuffer(abs(exponent), 3, &digitout);
|
||||
}
|
||||
|
||||
// Make sure no rounding error is returned
|
||||
if (buf->Is("-0"))
|
||||
{
|
||||
buf->Empty();
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
return buf->GetString();
|
||||
}
|
||||
|
||||
void PositionalNumeralSystem::IntegerToBuffer(double value, unsigned int digits, int *outdigits) const
|
||||
{
|
||||
static const char *alphaNumerics = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
unsigned int count = 0;
|
||||
char *chars = new char[128];
|
||||
char *start = chars;
|
||||
|
||||
do
|
||||
{
|
||||
count++;
|
||||
unsigned int intremainder = static_cast<unsigned int>(trunc(fmod(value, base)));
|
||||
*chars++ = alphaNumerics[intremainder];
|
||||
value /= base;
|
||||
} while (value >= 1.0);
|
||||
|
||||
unsigned int n = count;
|
||||
unsigned int q = digits;
|
||||
chars--;
|
||||
|
||||
while (n-- != 0 && q-- != 0)
|
||||
{
|
||||
buf->Append(*chars--);
|
||||
}
|
||||
|
||||
n++;
|
||||
while (n-- != 0)
|
||||
{
|
||||
buf->Append('0');
|
||||
}
|
||||
|
||||
*outdigits = count;
|
||||
delete[] start;
|
||||
}
|
||||
|
||||
Number *PositionalNumeralSystem::Parse(const char *text, unsigned int *length, char **end)
|
||||
{
|
||||
unsigned int intbase = static_cast<unsigned int>(base);
|
||||
char maxNumeric = (intbase > 10 ? 10 : intbase) + '0' - 1;
|
||||
char maxAlpha = intbase > 10 ? intbase + 'A' - 11 : 0;
|
||||
|
||||
unsigned int pos = 0;
|
||||
double integer = 0;
|
||||
double addition;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != 0 && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10)) * 1.0;
|
||||
integer = integer * base + addition;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
// Digits not found
|
||||
if (pos == 0)
|
||||
{
|
||||
*length = 0;
|
||||
*end = const_cast<char*>(text);
|
||||
return new RealNumber();
|
||||
}
|
||||
|
||||
double fraction = 0.0;
|
||||
double divisor = 1.0;
|
||||
if (*text == fractionPoint && fractionPoint != '\0')
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != '\0' && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10));
|
||||
fraction = fraction * base + addition;
|
||||
divisor *= base;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
double exp = 0.0;
|
||||
if (*text == 'e' || *text == 'E')
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
double sign = *text == '+' ? 1.0 : *text == '-' ? -1.0 : 0.0;
|
||||
|
||||
if (sign != 0.0)
|
||||
{
|
||||
text++;
|
||||
pos++;
|
||||
|
||||
while (*text != '\0' && ((*text >= '0' && *text <= maxNumeric) || (maxAlpha != 0 && *text >= 'A' && *text <= maxAlpha)))
|
||||
{
|
||||
addition = ((*text >= '0' && *text <= maxNumeric) ? (*text - '0') : (*text - 'A' + 10)) * 1.0;
|
||||
exp = exp * base + addition;
|
||||
text++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
exp *= sign;
|
||||
}
|
||||
else
|
||||
{
|
||||
text--;
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
*length = pos;
|
||||
*end = const_cast<char*>(text);
|
||||
|
||||
double dnumber = (integer + (fraction / divisor));
|
||||
|
||||
if (exp != 0.0)
|
||||
{
|
||||
// pow seems a bit off
|
||||
dnumber *= pow(base, exp + 4e-15);
|
||||
}
|
||||
|
||||
return new RealNumber(dnumber);
|
||||
}
|
||||
@@ -23,49 +23,46 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LANGUAGE_POSIX_H
|
||||
#define _LANGUAGE_POSIX_H
|
||||
#ifndef AMATH_NUMERAL_POSITIONAL_H
|
||||
#define AMATH_NUMERAL_POSITIONAL_H
|
||||
|
||||
#include "amath.h"
|
||||
#include "amathc.h"
|
||||
#include "language.h"
|
||||
#include "localize/lex.h"
|
||||
#include "localize/help.h"
|
||||
#include "localize/text.h"
|
||||
#include "localize/kword.h"
|
||||
#include "ntext.h"
|
||||
|
||||
#ifdef UNIX
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
class PosixLanguage : public Language {
|
||||
/**
|
||||
* @brief Base class for all numeral systems with a positional notation
|
||||
* @details
|
||||
* More info on positional notation is available at Wikipedia:
|
||||
* https://wikipedia.org/wiki/Positional_notation
|
||||
*/
|
||||
class PositionalNumeralSystem : public NumeralSystem
|
||||
{
|
||||
public:
|
||||
PosixLanguage();
|
||||
~PosixLanguage();
|
||||
char GetFractionPoint();
|
||||
bool CharIsAlNum(unsigned long character);
|
||||
bool CharIsAlpha(unsigned long character);
|
||||
bool CharIsDigit(unsigned long character);
|
||||
bool CharIsPunct(unsigned long character);
|
||||
bool CharIsSpace(unsigned long character);
|
||||
bool CharIsCntrl(unsigned long character);
|
||||
bool StrIsEqualLoc(const char *s1, const char *s2);
|
||||
bool Validate(char c);
|
||||
PositionalNumeralSystem(unsigned int base, unsigned int digits, const char fractionPoint);
|
||||
~PositionalNumeralSystem();
|
||||
|
||||
virtual const char* GetName();
|
||||
virtual const char* GetPrefix();
|
||||
virtual unsigned int GetDigits();
|
||||
virtual void SetDigits(unsigned int digits);
|
||||
virtual const char GetFractionPoint();
|
||||
virtual void SetFractionPoint(const char fractionPoint);
|
||||
virtual const char* GetText(Number* number);
|
||||
virtual Number* Parse(const char* text, unsigned int* length, char** end);
|
||||
|
||||
protected:
|
||||
char* Translate(textdef *def);
|
||||
char* Translate(helptextdef *def);
|
||||
char* Translate(identhelpdef *def);
|
||||
const char* GetSpecialCase(Number *number);
|
||||
void IntegerToBuffer(double value, unsigned int digits, int* outdigits) const;
|
||||
|
||||
double base;
|
||||
unsigned int digits;
|
||||
char fractionPoint;
|
||||
|
||||
private:
|
||||
locale_t locale;
|
||||
struct lconv *conv;
|
||||
const char* GetText(double number) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+25
-11
@@ -23,7 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Project homepage:
|
||||
* http://amath.innolan.net
|
||||
* https://amath.innolan.net
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -36,14 +36,27 @@
|
||||
|
||||
/**
|
||||
* @file numb.h
|
||||
* @brief Class base handling of numbers.
|
||||
*
|
||||
* @brief Class base handling of numbers
|
||||
*/
|
||||
|
||||
#include "amath.h"
|
||||
|
||||
union FloatUnion64 {
|
||||
bool IsNegative() const { return (integer >> 63) != 0; }
|
||||
bool IsZero() const { return integer == 0; }
|
||||
bool IsInf() const { return GetExponent() == 0x7FF && GetMantissa() == 0; }
|
||||
bool IsNaN() const { return GetExponent() == 0x7FF && GetMantissa() != 0; }
|
||||
bool IsMaxPositive() const { return integer == 0x7EFFFFFFFFFFFFFFull; }
|
||||
bool IsMaxNegative() const { return integer == 0x7FFFFFFFFFFFFFFFull; }
|
||||
int32_t GetExponent() const { return (integer >> 52) & 0x7FF; }
|
||||
uint64_t GetMantissa() const { return integer & 0xFFFFFFFFFFFFFull; }
|
||||
double floatingPoint;
|
||||
uint64_t integer;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
nsysnatural,
|
||||
nsysinteger,
|
||||
nsysrational,
|
||||
nsysreal,
|
||||
nsyscomplex,
|
||||
@@ -68,10 +81,10 @@ public:
|
||||
virtual bool PureComplexValue() = 0;
|
||||
virtual int GetPrecedence() = 0;
|
||||
virtual int GetDefaultPrecedence() = 0;
|
||||
virtual bool IsNegative() = 0;
|
||||
virtual bool IsZero() = 0;
|
||||
virtual bool IsNaN() = 0;
|
||||
virtual bool IsTooSmall() = 0;
|
||||
virtual bool IsTooLarge() = 0;
|
||||
virtual bool IsInfinite() = 0;
|
||||
virtual bool IsNotImplemented() = 0;
|
||||
|
||||
virtual Number* Unary() = 0;
|
||||
@@ -102,6 +115,9 @@ public:
|
||||
virtual Number* Cosecant() = 0;
|
||||
virtual Number* Secant() = 0;
|
||||
virtual Number* Cotangent() = 0;
|
||||
virtual Number* Chord() = 0;
|
||||
virtual Number* ExSecant() = 0;
|
||||
virtual Number* ExCosecant() = 0;
|
||||
|
||||
virtual Number* ArcSine() = 0;
|
||||
virtual Number* ArcCosine() = 0;
|
||||
@@ -109,6 +125,9 @@ public:
|
||||
virtual Number* ArcCosecant() = 0;
|
||||
virtual Number* ArcSecant() = 0;
|
||||
virtual Number* ArcCotangent() = 0;
|
||||
virtual Number* ArcChord() = 0;
|
||||
virtual Number* ArcExSecant() = 0;
|
||||
virtual Number* ArcExCosecant() = 0;
|
||||
|
||||
virtual Number* HypSine() = 0;
|
||||
virtual Number* HypCosine() = 0;
|
||||
@@ -142,11 +161,6 @@ public:
|
||||
virtual Number* ArcHaCoVerSine() = 0;
|
||||
virtual Number* ArcHaCoVerCosine() = 0;
|
||||
|
||||
virtual Number* ExSecant() = 0;
|
||||
virtual Number* ExCosecant() = 0;
|
||||
virtual Number* ArcExSecant() = 0;
|
||||
virtual Number* ArcExCosecant() = 0;
|
||||
|
||||
friend class PositionalNumeralSystem;
|
||||
friend class DecimalSystem;
|
||||
friend struct IntegerNumber;
|
||||
|
||||
+465
-433
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user