org.luaj.vm2.lib.jse
Class JseMathLib

java.lang.Object
  extended by org.luaj.vm2.lib.MathLib
      extended by org.luaj.vm2.lib.jse.JseMathLib

public class JseMathLib
extends org.luaj.vm2.lib.MathLib

Subclass of LibFunction which implements the lua standard math library.

It contains all lua math functions, including those not available on the JME platform. See org.luaj.lib.MathLib for the exception list.

Typically, this library is included as part of a call to JsePlatform.standardGlobals()

 Globals globals = JsePlatform.standardGlobals();
 System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
  

For special cases where the smallest possible footprint is desired, a minimal set of libraries could be loaded directly via Globals#load(LuaValue) using code such as:

 Globals globals = new Globals();
 globals.load(new JseBaseLib());
 globals.load(new PackageLib());
 globals.load(new JseMathLib());
 System.out.println( globals.get("math").get("sqrt").call( LuaValue.valueOf(2) ) );
  

However, other libraries such as CoroutineLib are not loaded in this case.

This has been implemented to match as closely as possible the behavior in the corresponding library in C.

See Also:
LibFunction, JsePlatform, org.luaj.vm2.lib.jme.JmePlatform, JseMathLib, Lua 5.2 Math Lib Reference

Constructor Summary
JseMathLib()
           
 
Method Summary
 LuaValue call(LuaValue modname, LuaValue env)
           
 double dpow_lib(double a, double b)
          Faster, better version of pow() used by arithmetic operator ^
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JseMathLib

public JseMathLib()
Method Detail

call

public LuaValue call(LuaValue modname,
                     LuaValue env)

dpow_lib

public double dpow_lib(double a,
                       double b)
Faster, better version of pow() used by arithmetic operator ^



Copyright © 2007-2013 Luaj.org. All Rights Reserved.