muse_builtin_math.c File Reference

#include "muse_builtin_math.h"
#include <math.h>
#include <stdlib.h>

Include dependency graph for muse_builtin_math.c:


Defines

#define muse_floor   floor
#define muse_ceil   ceil

Typedefs

typedef double(*) unary_math_op_t (double)
 The type unary math operators.

Functions

muse_cell fn_add (muse_env *env, void *context, muse_cell args)
 (+ <numbers>).
muse_cell fn_sub (muse_env *env, void *context, muse_cell args)
 (- <numbers>).
muse_cell fn_mul (muse_env *env, void *context, muse_cell args)
 (* <numbers>).
muse_cell fn_div (muse_env *env, void *context, muse_cell args)
 (/ <numbers>).
muse_cell fn_idiv (muse_env *env, void *context, muse_cell args)
 (i/ numerator denominator).
muse_cell fn_mod (muse_env *env, void *context, muse_cell args)
 (% numerator denominator).
muse_cell fn_inc (muse_env *env, void *context, muse_cell args)
 (++ c).
muse_cell fn_dec (muse_env *env, void *context, muse_cell args)
 (-- c).
muse_cell fn_trunc (muse_env *env, void *context, muse_cell args)
 (trunc float-value).
muse_cell fn_rand (muse_env *env, void *context, muse_cell args)
 (rand M [N]).
muse_cell fn_pow (muse_env *env, void *context, muse_cell args)
 (pow base exponent).
muse_cell fn_unary_math (muse_env *env, void *fn, muse_cell args)
 The function that calls the supplied unary math operator in the "context" field on the given argument.
void muse_math_load_common_unary_functions ()
 Defines log, log10, sqrt, sin, cos, tan, etc.

Detailed Description

Author:
Srikumar K. S. (mailto:kumar@muvee.com)
Copyright (c) 2006 Jointly owned by Srikumar K. S. and muvee Technologies Pte. Ltd.

All rights reserved. See LICENSE.txt distributed with this source code or http://muvee-symbolic-expressions.googlecode.com/svn/trunk/LICENSE.txt for terms and conditions under which this software is provided to you.


Define Documentation

#define muse_floor   floor

#define muse_ceil   ceil


Typedef Documentation

typedef double(*) unary_math_op_t(double)

The type unary math operators.


Function Documentation

muse_cell fn_add ( muse_env env,
void *  context,
muse_cell  args 
)

(+ <numbers>).

add sums up all of its arguments and returns the result. The result will be an integer if all of its arguments are integers. Otherwise it'll be float.

muse_cell fn_sub ( muse_env env,
void *  context,
muse_cell  args 
)

(- <numbers>).

Takes 1 or more arguments.

muse_cell fn_mul ( muse_env env,
void *  context,
muse_cell  args 
)

(* <numbers>).

Multiplies all arguments. Result is float if at least one of the arguments is float. Otherwise it is an integer.

muse_cell fn_div ( muse_env env,
void *  context,
muse_cell  args 
)

(/ <numbers>).

Takes 1 or more arguments.

muse_cell fn_idiv ( muse_env env,
void *  context,
muse_cell  args 
)

(i/ numerator denominator).

Takes 2 arguments. Divides first by the second and returns the quotient. Arguments must be integers.

muse_cell fn_mod ( muse_env env,
void *  context,
muse_cell  args 
)

(% numerator denominator).

Takes 2 arguments and returns the floating point or integer remainder on dividing first by the second.

muse_cell fn_inc ( muse_env env,
void *  context,
muse_cell  args 
)

(++ c).

Increments the integer contents of the given cell.

muse_cell fn_dec ( muse_env env,
void *  context,
muse_cell  args 
)

(-- c).

Decrements the integer contents of the given cell.

muse_cell fn_trunc ( muse_env env,
void *  context,
muse_cell  args 
)

(trunc float-value).

Converts a float to int. If given an integer argument. returns it as is.

muse_cell fn_rand ( muse_env env,
void *  context,
muse_cell  args 
)

(rand M [N]).

Generates a random number.

muse_cell fn_pow ( muse_env env,
void *  context,
muse_cell  args 
)

(pow base exponent).

Computes base ^ exponent. The result is always a float.

muse_cell fn_unary_math ( muse_env env,
void *  fn,
muse_cell  args 
)

The function that calls the supplied unary math operator in the "context" field on the given argument.

The supported unary math operations are -

void muse_math_load_common_unary_functions (  ) 

Defines log, log10, sqrt, sin, cos, tan, etc.


Generated on Mon Sep 25 23:12:47 2006 for muSE by  doxygen 1.4.7