NAME
Math::SlideRule - slide rule support for Perl
SYNOPSIS
Simulate an analog computer (without much nuance).
*** BETA interface, may change without warning ***
use Math::SlideRule;
my $sr = Math::SlideRule->new();
$sr->round(1.234); # 1.23 via sprintf()
# scientific notation breakdown
$sr->standard_form(1234); # [ 1.234, 3 ]
$sr->divide(75, 92);
$sr->multiply(1.5, 3.7);
$sr->multiply(-1.1, 2.2, -3.3, 4.4);
DESCRIPTION
Slide rule support for Perl. More rounding than perhaps is necessary is the main feature of this module. Math::SlideRule::PickettPocket approximates a N 3P-ES pocket slide rule.
METHODS
Calls will croak
or die
if something goes awry.
round
rounds the input number via sprintf
. It should be overridden in any subclasses to suit the particulars of the slide rule being implemented. Otherwise is mostly used internally.
standard_form
returns a number as a list consisting of the characteristic and exponent of that number. Mostly used internally by various other routines.
multiply
requires two (or more) numbers, multiples them, returns result. There's a divide
as well. (There is no support for the combined multiplication and division tricks possible on a slide rule.)
BUGS
Reporting Bugs
If the bug is in the latest version, send a report to the author. Patches that fix problems or add new features are welcome.
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-SlideRule
http://github.com/thrig/Math-SlideRule
Known Issues
round
will need to be modified to specify what sort of rounding need be done, as the various scales have various resolutions possible (and may vary by the number under consideration, as square roots divide the scale into two, and cube roots that same space into three).
A more realistic implementation might use XS, and malloc
a large amount of contiguous memory, and then "slide" pointers around therein to represent where the slider and hairline are. The scales would be mapped into this region of memory, so that address 0x0
would be 1
of the D scale, and the highest memory address 10 of that scale, and the other values laid out as appropriate between those posts. With a large amount of memory, suitable resolution might be gained, though rounding would be necessary for the many results that would fall into memory addresses not associated with some tick mark of the scale in question. (That the slider needs be movable and therefore the mapping of any scales on it might be tricky?)
AUTHOR
Jeremy Mates, <jmates at cpan.org>
LICENSE AND COPYRIGHT
Copyright 2014 Jeremy Mates.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.