[system] / trunk / pg / lib / Value / Real.pm Repository:
ViewVC logotype

Log of /trunk/pg/lib/Value/Real.pm

Parent Directory Parent Directory


Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 6118 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Oct 1 14:10:02 2009 UTC (10 years, 4 months ago) by dpvc
File length: 5882 byte(s)
Diff to previous 5696
Fix error message for powers of negatives

Revision 5696 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 14 12:14:21 2008 UTC (11 years, 8 months ago) by dpvc
File length: 5870 byte(s)
Diff to previous 5600
Added

	 no strict "refs"

to try to avoid new error checking in Perl 5.10.

Revision 5600 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jan 16 22:51:52 2008 UTC (12 years, 1 month ago) by dpvc
File length: 5852 byte(s)
Diff to previous 5468
Make sure that real and complex values have their contexts changed if
one is specified in the call to new().

Revision 5468 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Sep 8 21:33:53 2007 UTC (12 years, 5 months ago) by dpvc
File length: 5831 byte(s)
Diff to previous 5178
The make() method now inherits all the settings of the parent object,
so that flags set by the user (e.g., tolerances, periods, and so on)
will be passed on as new objects are created.  For example, in

     $x = Real(1)=>with(tolerance=>.0001);
     $y = sin($x);

$y will also have tolerance set to .0001.

This also applies to binary operations, where the result will now
inherit all the values of either operand, with the left-hand operand
taking precedence when they both have a flag set but to different
values.

This is a significant change, and there may be unforeseen side effects
that I'll have to take care of as they appear.  It passes my test
suite, however, so I'm hoping they will be limited.

Revision 5178 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jul 13 21:59:34 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5525 byte(s)
Diff to previous 5170
Make periodic comparisons have their tolerances based on the correct
answer point rather than just the period.  (This avoids zeroLevel
checks on one coordiante when period is pure imaginary or pure real.)

Also fixed promote() calls since it has been moved to Value.pm.

Revision 5170 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jul 13 20:50:45 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5370 byte(s)
Diff to previous 5115
Make Real and Complex objects promote their period fields so that they
can be specified as strings rather than actual objects.

Also make the default promote() routine be the more sophisticated one
used by Real and Complex (and so remove the reoutine from those objects).

Revision 5115 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 2 23:48:00 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5713 byte(s)
Diff to previous 5112
Get the period and logperiodic values using getFlags rather than only
looking in the object itself (this allows it to inherit the values
from a Formula, for example).

Revision 5112 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 2 16:18:49 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5695 byte(s)
Diff to previous 5089
Make getFlag() look for an {equation} field and add that into the
search path for the flag.  This lets Formula object tag their results
so that printing and comparisons will use the flags from the Formula
for formats and tolerances.

Revision 5089 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 29 22:07:10 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5697 byte(s)
Diff to previous 5084
Transfer flags from parent objects to their children for comparisons
and printing purposes.  Also touch up a few type-coersion issues.  (It
may be possible to not to need Value::isValue() if these can all be
taken care of.)

Revision 5084 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 29 19:11:05 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5675 byte(s)
Diff to previous 5042
Adjusted some of the type checking to use more appropriate tests.

Revision 5042 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 28 01:31:09 2007 UTC (12 years, 7 months ago) by dpvc
File length: 5674 byte(s)
Diff to previous 5012
Recent changes to automatically do promotion in the Value methods was
a mistake.  I put it back into the subclass methods again.

Revision 5012 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 21 23:10:13 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5562 byte(s)
Diff to previous 5006
Added Package method to the Context object to replace the
Value->Package() calls and simplify the $self->Package calls (don't
have to look up the context again).

Revision 5006 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 16 02:08:02 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5533 byte(s)
Diff to previous 4996
Fixed an error with the modulo method, and adjusted formatting.

Revision 4996 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Jun 10 11:34:27 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5551 byte(s)
Diff to previous 4991
Allow promote() to accept a context as the first argument so that the
promoted object can be forced into the given context.

Revision 4991 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 8 02:09:21 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5453 byte(s)
Diff to previous 4987
Update new() and make() methods to accept a context as the first
parameter (making it easier to create objects in a given context
without having to resort to a separate call to coerce them to the
given context after the fact).

Revision 4987 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 21:54:46 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5374 byte(s)
Diff to previous 4979
Added Value->Package(name[,context]) to look up what package is
currently set to handle the named type.  E.g.,
Value->Package("Complex") usually returns "Value::Complex".  These can
be overridden in the Context so that modified vesions of the
MathObjects can be made to replace the existing ones more easily.  In
particular, the Parser classes should call these (not yet implemented)
when they create objects, so that you can override the object they
create.

Also cleaned up some more context issues (with still more to come).

Revision 4979 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 11:59:05 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5363 byte(s)
Diff to previous 4976
More updates for marking MathObjects with the context in which they
were created, so they should now work like the Formula objects in that
respect.  As they are combined via overloaded operators, they should
pass on their contexts correctly.

Also normalized the use of getFlag() to obtain flags from the
MathObject's context rather than looking in the context directly.
This allows the math object to override the flag by setting the flag
value in the object's hash (e.g., $f->{tolerance} = .001).  I've also
added the ability to override context flags via the answerHash (e.g.,
$f->cmp(tolerance => .001)), though some filtering may need to be
added to this at some point.  Note that ONLY the context flags can be
overridden, not other parts of the context.

Revision 4976 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 6 23:00:14 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5335 byte(s)
Diff to previous 4975
Added comparisons for periodic reals and complex numbers (numbers that
match up to reduction module some number).  This makes
contextPeriodic.pl obsolete, but the problems that use it should not
need to change.  (It would be good to remove the loadMacros() call,
however.)

Reals and Complex numbers now overload the % operator for the modulo
operation.

Revision 4975 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 6 21:44:05 2007 UTC (12 years, 8 months ago) by dpvc
File length: 5028 byte(s)
Diff to previous 4962
This begins some major updates to the Parser and Value libraries.
This may make the MathObjects unstable as things shake down, but I'll
try to keep that to a minimum.

This update reorganizes how the overloading of operations are
implemented.  The base Value class is now overloaded rather than the
individual Value classes.  This makes it easier to make subclasses
that take advantage of the overloading.

The code that handles promoting one MathObject to another has been
updated as a part of this.  This should also make subclassing the
existing MathObjects more flexible.

In the past, Formula objects included a pointer to the Context in
which the object was created, but other MathObject did not.  This
update is the first round of updates to include the context in the
other MathObjects, but more work needs to be done.

The changes here should not affect existing problems; it is possible
that some macro files will need to be updated, but none of the
standard ones in pg/macros seem to need it at the moment.

Revision 4962 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed May 16 00:36:37 2007 UTC (12 years, 9 months ago) by dpvc
File length: 6080 byte(s)
Diff to previous 4844
Allow Real object to override the context's number format by setting
its format field.  E.g.:

    Real(1.2345)->with(format=>"%.2f")

Revision 4844 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Mar 6 01:51:12 2007 UTC (12 years, 11 months ago) by gage
File length: 6030 byte(s)
Diff to previous 4144
Format fix

Revision 4144 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 23 22:07:44 2006 UTC (13 years, 8 months ago) by dpvc
File length: 6020 byte(s)
Diff to previous 3992
Use tolerance flags from the Real object itself, if available, before
looking at the context.

Revision 3992 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jan 30 16:20:09 2006 UTC (14 years ago) by dpvc
File length: 6122 byte(s)
Diff to previous 3716
When checking for division by zero, don't do fuzzy check.

Revision 3716 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Oct 16 03:37:17 2005 UTC (14 years, 4 months ago) by dpvc
File length: 6111 byte(s)
Diff to previous 3596
In the past, when Value objects were inserted into strings, they would
automatically include parentheses so that if you had $f equal to 1+x
and $g equal to 1-x, then Formula("$f/$g") would mean (1+x)/(1-x)
rather than 1+(x/1)-x, which is what would happen as a straing string
substitution.

The problem is that this would also happen for real numbers, vectors,
and everything else, even when it wasn't necessary.  So if $x=Real(3),
then "Let x = $x" would be "Let x = (3)".

I have changed the behavior of the string concatenation for Value
objects so that parentheses are only added in a few cases: for
Formulas, Complex numbers, and Unions.  This makes the other Value
objects work more like regular variables in strings, but might cause
some problems with strings that are used as formulas.  For example, if
$a = Real(-3), then "x + 2 $a" will become "x + 2 -3", or "x-1" rather
than the expected "x - 6".  (The old approach would have made it "x +
2 (-3)" which would have worked properly).  For the most part, it is
easier to use something like "x + 2*$a" or even "x" + 2*$a in this
case, so the extra trouble of having to avoid parentheses when you
really meant to substitute the value into a string didn't seem worth
it.

Revision 3596 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Sep 2 22:29:59 2005 UTC (14 years, 5 months ago) by dpvc
File length: 6104 byte(s)
Diff to previous 3562
Fixed error in atan2 where second argument was not promoted to a Real.

Revision 3562 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Aug 24 19:07:10 2005 UTC (14 years, 5 months ago) by dpvc
File length: 6021 byte(s)
Diff to previous 3370
Changed stringify to check for an answer that is zero by using the
zeroLevelTol value directly (rather than use the fuzzy equality check
for zero, which depends on the tolType in a bad way).

Revision 3370 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jul 12 22:29:53 2005 UTC (14 years, 7 months ago) by dpvc
File length: 6014 byte(s)
Diff to previous 3341
A first pass at making parser error messages localizable.  The
Context()->{error}{msg} hash can be used to specify translations of
the standard messages.  For example,

    Context()->{error}{msg}{'Division by zero'} = "Don't divide by zero, dude!";
    Context()->{error}{msg}{'Function '%s' has too many inputs'} =
        "You passed too many arguments to '%s'";

(I didn't translate into another language, here, but you could do
that, too.)

The msg hash could also be used within answer checkers to make certain
answer messages more appropriate for the given type of expected answer.

Revision 3341 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 4 15:43:53 2005 UTC (14 years, 7 months ago) by dpvc
File length: 6012 byte(s)
Diff to previous 3261
Implement "remove trailing zeros" format, like in prfmt().  I still
think '%g' works better in most cases ('%f#' will print larger values
without using scientific notation, which is nice, but will print small
numbers like .000000005 as 0, even though the fuzzy comparison of this
to zero will not be true.)

Revision 3261 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 4 13:50:41 2005 UTC (14 years, 8 months ago) by dpvc
File length: 5968 byte(s)
Diff to previous 3192
Avoid possible infinite loop with length and typeref calls.

Revision 3192 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Mar 16 13:30:28 2005 UTC (14 years, 11 months ago) by dpvc
File length: 5953 byte(s)
Diff to previous 3171
Update the overloaded operators so that they can be overridden by
subclasses of the predefined object classes.  This involves calling
the objects method rather than using a hard reference to the routine
in the parent class.

Also, change the name of the string comparison routine to
compare_string to avoid conflicts with cmp that is used to produce the
answer checker for the class.

Finally, in Value.pm, promotePrecedence no longer has to do fancy
footwork to get "special" precedence to work (this was a hack to get
around the misfeature of the overloaded operators -- now that that is
being handled correctly, there is no need for it).

Revision 3171 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Feb 15 21:53:23 2005 UTC (15 years ago) by dpvc
File length: 5805 byte(s)
Diff to previous 3166
Improved the Real(), Complex(), Point(), Vector(), Matrix() and
String() constructors so that they will process formulas passed to
them as strings rather than requiring perl objects for these.

For example, you can use Real("2/3") rather than Real(2/3) if you
want.  Also, Real("1+x") will return a formula returning a real
(essentially the same as Formula("1+x") in this case).

Revision 3166 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Feb 15 02:20:52 2005 UTC (15 years ago) by dpvc
File length: 5654 byte(s)
Diff to previous 3165
Fixed an error with Matrix() that could cause it to loop infinitely
when bad data is passed to it.

Also, allow Matrix(), Point(), Vector(), and Real() to accept string
values that are evaluated to produce the value returned.

(Sorry, accidentally committed with a blank message.)

Revision 3165 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Feb 15 02:16:10 2005 UTC (15 years ago) by dpvc
File length: 5658 byte(s)
Diff to previous 2908
*** empty log message ***

Revision 2908 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Oct 12 20:46:43 2004 UTC (15 years, 4 months ago) by dpvc
File length: 5695 byte(s)
Diff to previous 2800
Report errors for powers of negative numbers rather than return 'nan'.
Don't allow 'nan' to be made into a Real object.

Revision 2800 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Sep 19 14:27:39 2004 UTC (15 years, 5 months ago) by dpvc
File length: 5350 byte(s)
Diff to previous 2625
Added isZero and isOne checks for Parser::Value objects (i.e., for
constants within formulas).  These now correctly handle vector and
matrices, in particular.  The isOne and isZero checks are used in the
reduce() method to simplify formulas.

Revision 2625 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 16 18:35:12 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5297 byte(s)
Diff to previous 2615
Added string comparison to all Value object classes (to compare the
string value of an object to another string).

Overloaded perl '.' operator to do dot product when the operands are
formulas returning vectors.  (Part of the auto-generation of
formulas).

A few improvements to real and complex class output results.

Made Union class slightly more robust and removed need for makeUnion
method other than in the Union itself.

Revision 2615 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 14 21:27:45 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5267 byte(s)
Diff to previous 2612
*** empty log message ***

Revision 2612 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 14 19:29:42 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5364 byte(s)
Diff to previous 2606
Fixed some bugs in the handle of the context in ->string and ->TeX
methods of Value objects.

Revision 2606 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 14 11:25:47 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5328 byte(s)
Diff to previous 2603
Can now specify that the objects stringify themselfs in their TeX
forms rather than their answer-string forms.  This makes it easier to
use the objects in the text of a problem (without having to call ->TeX
explicitly each reference).

Use

       Context()->texStrings

to start outputting TeX strings, and

      Context()->normalStrings

to switch back.

Revision 2603 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 13 23:01:07 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5352 byte(s)
Diff to previous 2597
Added an Infinite object class for the Value package.  Still need to
add it to the Parser package.

Revision 2597 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 13 11:38:22 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5292 byte(s)
Diff to previous 2592
Added answer checker for parallel vectors.
Added option to number checker to have it not report type mismatches
for the known strings (like 'infinity').  (Really need a class for
infinities, and a Value.pm class for strings.)

Revision 2592 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 12 16:40:47 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5230 byte(s)
Diff to previous 2580
A number of small fixes.  Most were to fix minor bugs in string and
TeX output, particulary for the various list-based objects (like
vectors, intervals, etc.).  There were also some bug fixes in the
comparison routines.  Some additional checks were added for valid
intervals when the coordinates are formulas.

Revision 2580 - (view) (download) (as text) (annotate) - [select for diffs]
Added Mon Aug 9 21:38:58 2004 UTC (15 years, 6 months ago) by dpvc
File length: 5168 byte(s)
Forgot to add this file.  It implements the "fuzzy real" class.

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9