Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

mj_math.h File Reference

#include <math.h>

Go to the source code of this file.


#define MJ_pi   3.1415926535897931
 The value of pi.

#define MJ_2pi   6.2831853071795862
 The value of 2 * pi.

#define MJ_piSquared   9.869604401089358
 The value of pi^2.

#define MJ_pi2   1.57079632679489660000
 The value of pi / 2.

#define MJ_pi4   0.78539816339744828
 The value of pi / 4.

#define MJ_ln2   0.693147180559945290
 The value of ln(2).

#define MJ_ln22   0.346573590279972640
 The value of ln(2) / 2.


float MJ_abs (float x1)
 Absolute value.

unsigned long MJ_abs (unsigned long x1)
 Null function needed for templates.

float MJ_centToMul (float cents)
 Convert pitch relative cents to multiplier.

float MJ_mulToCent (float mul)
 Convert multiplier to relative pitch.

double MJ_centToMul (double cents)
 Convert pitch relative cents to multiplier.

double MJ_mulToCent (double mul)
 Convert multiplier to relative pitch.

Detailed Description

Overloaded mathematical functions.


Standard libm defines functions with different names for different data types. This is a problem, if you typedef variables and want to change the type afterwards - by default the functions remain what they were, resulting in either loss of precicion (float to double change) or excessive precision (double to float). The same problem arises with template systems.

To make the transition between data types transparent, Mustajuuri defines an overloaded series of common mathematics functions with the same name and both float and double arguments.

Besides the inline wrappers, mj_math also introduces some useful functions usually available as macros - minimum and maximum value for example. Function is better than macro.

There are also some useful constants (pi, ln(2) etc.)

Generated at Sun Jan 18 20:51:22 2004 for Jezabel by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001