view mayachemtools/docs/modules/html/MathUtil.html @ 9:ab29fa5c8c1f draft default tip

Uploaded
author deepakjadmin
date Thu, 15 Dec 2016 14:18:03 -0500
parents 73ae111cf86f
children
line wrap: on
line source

<html>
<head>
<title>MayaChemTools:Documentation:MathUtil.pm</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
</head>
<body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
<br/>
<center>
<a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
</center>
<br/>
<div class="DocNav">
<table width="100%" border=0 cellpadding=0 cellspacing=2>
<tr align="left" valign="top"><td width="33%" align="left"><a href="./HTMLUtil.html" title="HTMLUtil.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./Matrix.html" title="Matrix.html">Next</a></td><td width="34%" align="middle"><strong>MathUtil.pm</strong></td><td width="33%" align="right"><a href="././code/MathUtil.html" title="View source code">Code</a>&nbsp;|&nbsp;<a href="./../pdf/MathUtil.pdf" title="PDF US Letter Size">PDF</a>&nbsp;|&nbsp;<a href="./../pdfgreen/MathUtil.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a>&nbsp;|&nbsp;<a href="./../pdfa4/MathUtil.pdf" title="PDF A4 Size">PDFA4</a>&nbsp;|&nbsp;<a href="./../pdfa4green/MathUtil.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
</table>
</div>
<p>
</p>
<h2>NAME</h2>
<p>MathUtil</p>
<p>
</p>
<h2>SYNOPSIS</h2>
<p>use MathUtil;</p>
<p>use MathUtil qw(:all);</p>
<p>
</p>
<h2>DESCRIPTION</h2>
<p><strong>MathUtil</strong> module provides a variety of common math functions not available in core
Perl package or some other useful math utilities. In order to be consistent with other
Perl functions, name of all the functions in this package are in lowercase which differs
from MayaChemTools naming convention for function names.</p>
<p><strong>MathUtil</strong> module provides the following functions:</p>
<p> <a href="#generateprimenumbersuptocount">GeneratePrimeNumbersUpToCount</a>, <a href="#generateprimenumbersuptolimit">GeneratePrimeNumbersUpToLimit</a>, <a href="#acos">acos</a>, <a href="#asin">asin</a>, <a href="#ceil">ceil</a>
, <a href="#floor">floor</a>, <a href="#log10">log10</a>, <a href="#max">max</a>, <a href="#min">min</a>, <a href="#random">random</a>, <a href="#round">round</a>, <a href="#srandom">srandom</a>, <a href="#tan">tan</a>
</p><p>
</p>
<h2>FUNCTIONS</h2>
<dl>
<dt><strong><a name="generateprimenumbersuptocount" class="item"><strong>GeneratePrimeNumbersUpToCount</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $PrimesRef = GeneratePrimeNumbersUpToCount();
<br/>    $PrimesRef = GeneratePrimeNumbersUpToCount($Count);</div>
<p>Generate prime numbers up to specified <em>Count</em> of prime numbers and return a
reference to an array containing the prime numbers.</p>
<p>By default, the first 1000 prime numbers are generated. The 1000th prime
number is 7919.</p>
<p>The algorithm to generate prime numbers is a modification of  Sieve of Erastothenes
prime number generator.</p>
</dd>
<dt><strong><a name="generateprimenumbersuptolimit" class="item"><strong>GeneratePrimeNumbersUpToLimit</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $PrimesRef = GeneratePrimeNumbersUpToLimit();
<br/>    $PrimesRef = GeneratePrimeNumbersUpToLimit($Limit);</div>
<p>Generate prime numbers up to a specified <em>Limit</em> and return a reference to an
array containing the prime numbers.</p>
<p>By default, the first 1000 prime numbers are generated. The 1000th prime
number is 7919 and that's why default limit is set to 7920.</p>
<p>The algorithm to generate prime numbers is a modification of  Sieve of Erastothenes
prime number generator.</p>
</dd>
<dt><strong><a name="acos" class="item"><strong>acos</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Value = acos($AngleInRadians);</div>
<p>Returns the nverse cosine of an angle expressed in <em>Radians</em> using Math::Trig::acos
function.</p>
</dd>
<dt><strong><a name="asin" class="item"><strong>asin</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Value = asin($AngleInRadians);</div>
<p>Returns the inverse sine of an angle expressed in <em>Radians</em> using Math::Trig::asin
function.</p>
</dd>
<dt><strong><a name="ceil" class="item"><strong>ceil</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $IntegerValue = ceil($Value);</div>
<p>Returns the next largest integer for <em>Value</em> using POSIX::ceil function.</p>
</dd>
<dt><strong><a name="floor" class="item"><strong>floor</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $IntegerValue = floor($Value);</div>
<p>Returns the previous smallest integer for <em>Value</em> using POSIX::floor function.</p>
</dd>
<dt><strong><a name="log10" class="item"><strong>log10</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Log10Value = log10($Value);</div>
<p>Returns the log of <em>Value</em> using base 10.</p>
</dd>
<dt><strong><a name="max" class="item"><strong>max</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Number = max($Number1, $Number2);</div>
<p>Returns a <strong>Number</strong> corresponding to the maximum of <em>Number1</em> and <em>Number2</em>.</p>
</dd>
<dt><strong><a name="min" class="item"><strong>min</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Number = min($Number1, $Number2);</div>
<p>Returns a <strong>Number</strong> corresponding to the minimum of <em>Number1</em> and <em>Number2</em>.</p>
</dd>
<dt><strong><a name="round" class="item"><strong>round</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $RoundedValue = round($Number);
<br/>    $RoundedValue = round($Number, $DecimalPlaces);</div>
<p>Returns a value corresponding to a nearst ingeter for <em>Number</em> or formatted to <em>DecimalPlaces</em>.</p>
</dd>
<dt><strong><a name="random" class="item"><strong>random</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $RandomNumber = random();
<br/>    $RandomNumber = random($Size);</div>
<p>Returns a random number between 0 and less than 1 or specified size.</p>
<p>The random number generator implemented in MayaChemTools is a variant of linear
congruential generator (LCG) as described by Miller et al. [ Ref 120 ]. It is
also referred to as Lehmer random number generator or Park-Miller random number
generator.</p>
<p>Unlike Perl's core random number generator function rand, the random number
generator implemented in MayaChemTools generates consistent random values
across different platforms - Windows, CygWin, Linux, Unix - for a specific random
seed.</p>
</dd>
<dt><strong><a name="srandom" class="item"><strong>srandom</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Seed = srandom($Seed);</div>
<p>Sets random number seed to be used by &lt;random&gt; function and returns seed value.</p>
<p>The random number seed is recommeded to be an integer between 1 and 2**31 - 2
[Ref 120] which translates to be 1 and 2147483646.</p>
<p>The default seed is set to 123456789.</p>
</dd>
<dt><strong><a name="tan" class="item"><strong>tan</strong></a></strong></dt>
<dd>
<div class="OptionsBox">
    $Value = tan($AngleInRadians);</div>
<p>Returns the tangent of an angle expressed in <em>Radians</em>.</p>
</dd>
</dl>
<p>
</p>
<h2>AUTHOR</h2>
<p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
<p>
</p>
<h2>SEE ALSO</h2>
<p><a href="./Constants.html">Constants.pm</a>,&nbsp<a href="./ConversionsUtil.html">ConversionsUtil.pm</a>
</p>
<p>
</p>
<h2>COPYRIGHT</h2>
<p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
<p>This file is part of MayaChemTools.</p>
<p>MayaChemTools is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.</p>
<p>&nbsp</p><p>&nbsp</p><div class="DocNav">
<table width="100%" border=0 cellpadding=0 cellspacing=2>
<tr align="left" valign="top"><td width="33%" align="left"><a href="./HTMLUtil.html" title="HTMLUtil.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./Matrix.html" title="Matrix.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>MathUtil.pm</strong></td></tr>
</table>
</div>
<br />
<center>
<img src="../../images/h2o2.png">
</center>
</body>
</html>