Git Product home page Git Product logo

tmath's Introduction

TMath Build status

A small math function collection based on the Taylor expansion series.

Building the project

  • Download the source files from the master-tree
  • To build the project, you need to have g++ and make installed
  • And you need to run export CC=g++
  • If everything is ready, run make and ...
  • ... your libtmath.a library file is ready in the lib folder

How to use

Just build it as described above, include the header files and link the library. The library uses the types TMath::DOUBLE(long double) and TMath::LONG(long long) for parameters and return values.

What is included?

Mathematical functions

Function Description
sin(DOUBLE x) sine of x
asin(DOUBLE x) arcsine of x
sinh(DOUBLE x) hyperbolic sine of x
cos(DOUBLE x) cosine of x
acos(DOUBLE x) arccosine of x
cosh(DOUBLE x) hyperbolic cosine of x
tan(DOUBLE x) tangent of x
atan(DOUBLE x) arctangent of x
cot(DOUBLE x) cotangent of x
acot(DOUBLE x) arccotangent of x
coth(DOUBLE x) hyperbolic cotangent of x
sec(DOUBLE x) secant of x
asec(DOUBLE x) arcsecant of x
sech(DOUBLE x) hyperbolic secant of x
cosec(DOUBLE x) cosecant of x
acsc(DOUBLE x) arccosecant of x
csch(DOUBLE x) hyperbolic cosecant of x
floor(DOUBLE x) next lower integer of x
ceil(DOUBLE x) next higher integer of x
mod(LONG x, LONG y) the remainder of the division x / y
exp(DOUBLE x) natural exponential function
sqrt(DOUBLE x) squareroot of x
root(DOUBLE x, DOUBLE n) n-th root of x
ln(DOUBLE x) natural logarithm of x
lg(DOUBLE x) common logarithm of x
lb(DOUBLE x) binary logarithm of x
log(DOUBLE x, DOUBLE n) logarithm with base n of x
pow(DOUBLE x, DOUBLE n) x to the power of n
pow(LONG x, LONG n) x to the power of n
pow(DOUBLE x, LONG n) x to the power of n
fac(LONG n) factorial of n
facd(LONG n) factorial of n using floating point
oddfac(LONG n) odd-factorial of n
oddfacd(LONG n) odd-factorial of n using floating point
rad(DOUBLE x) degrees to radiant
deg(DOUBLE x) radiant to degrees
abs(DOUBLE x) absolute value of x
equal(DOUBLE x, DOUBLE y) floating-point number equality
equal(DOUBLE x, DOUBLE y, DOUBLE eps) floating-point number equality with a variance of epsilon

Vector class

To initialize a new vector just use initializer lists (like Vector {1, 2, 3}) or create a null-vector using Vector(n) (where n is the number of dimensions).

Operation Description
a[n] Access the n-th element of the vector a
a.at(n) Access the n-th element of the vector a as a constant
a + b Adds vector a and b
a - b Subtracts vector a from b
a * s Scales the vector by the factor s
a / s Scales the vector by the factor 1 / s
a == b Tests if vector a is equal to b
a != b Tests if vector a is not equal to b
a.equal(b, e) Tests if the vector a is equal to b with the accuracy e
a.dot(b) Dot product of a and b.
a.cross(b) Cross product of a and b
a.norm() Normalized copy of the vector a
a.length() Length of vector a
a.dim() Dimensions of vector a
a.to_string() Generates a string representation of the vector a

Matrix class

To initialize a new matrix you can use initializer lists (like Matrix{{1, 0}, {0, 1}}) or create a null-matrix using Matrix(x, y) (where x is the number of cols and y the number of rows).

Operation Description
m[n] Access the n-th row of the matrix
m[n][x] Access the element at row n and col x
m.at(n) Access the n-th row of the matrix as a constant
m.at(n, x) Access the element at row n and col x as a constant
m * v Multiply matrix m with vector v
m * a Multiply matrix m with matrix a
m * s Multiply matrix m with scalar s
-m Negate matrix m
a + b Add the matrices
a - b Subtract the matrices
a.equal(b, e) Tests if the matrix a is equal to b with the accuary e
a == b Tests if the matrix a is equal to b
a != b Tests if the matrix a is not equal to b
a.colCount() Get the number of matrix cols
a.rowCount() Get the number of matrix rows
a.to_string() Generate a string representation of the matrix
identity(n) Generates an identity matrix of dimension n

What is planned?

  • Statistics
  • Numerics (e.g. solvers for ODE/PDE/LS)

tmath's People

Contributors

lnsp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jrmwng

tmath's Issues

Split up the large tmath.cpp file

Splitting up the large tmath.cpp file into logical units (like the tests) helps to maintain the project.

The logical units are

  • abs.cpp
  • cosecant.cpp
  • cosine.cpp
  • cotangent.cpp
  • degrad.cpp
  • equality.cpp
  • explog.cpp
  • factorial.cpp
  • fcm.cpp
  • power.cpp
  • roots.cpp
  • secant.cpp
  • sine.cpp
  • tangent.cpp
  • vector.cpp

Vector data structure

The vector data structure is an important part of the next release. Also including vector operations like adding and subtracting, dot and cross product.

1 ร— 1 = 1

in the for-loop of the pow functions and the fac function, 1 ร— 1 = 1 in the first iteration. therefore that iteration can be eliminated

Remove Vagrantfile

Vagrant is not necessarily needed to build the project anymore since it's build chain supports only Linux and macOS and therefore all users are restricted to these operating systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.