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

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

Parent Directory Parent Directory


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

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: 10600 byte(s)
Diff to previous 5433
Added

	 no strict "refs"

to try to avoid new error checking in Perl 5.10.

Revision 5433 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 26 19:05:18 2007 UTC (12 years, 5 months ago) by dpvc
File length: 10582 byte(s)
Diff to previous 5430
Improve error messages for unreduced unions.

Revision 5430 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 26 12:13:12 2007 UTC (12 years, 5 months ago) by dpvc
File length: 10574 byte(s)
Diff to previous 5427
Had the test reversed in isReduced when returning a boolean rather
than an array (Argh!)

Revision 5427 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 26 03:02:06 2007 UTC (12 years, 5 months ago) by dpvc
File length: 10574 byte(s)
Diff to previous 5405
Minor change (don't need to check for isValue since we are already
assuming that in the previous line).

Revision 5405 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Aug 22 23:38:13 2007 UTC (12 years, 5 months ago) by dpvc
File length: 10596 byte(s)
Diff to previous 5100
Revamp the isReduced() method for Unions and Sets so that it produces
error indicators in addition to the T/F result.  The answer checker
now uses that to produce more meaningful error messages for students
(in the past it always said "Your union can be produced without
overlaps" even when that was not the actual reason why the union is
not reduced).

Revision 5100 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 30 15:07:45 2007 UTC (12 years, 7 months ago) by dpvc
File length: 9994 byte(s)
Diff to previous 5097
Maintain context in a number of places where it was being lost.
Properly create Intervals from List and Point objects, when apropriate.
Properly create Formulas from non-constant Unions.
Properly report whether Unions of single items are reduced.
Only add parentheses when needed in stringify.

Revision 5097 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 30 02:39:10 2007 UTC (12 years, 7 months ago) by dpvc
File length: 9449 byte(s)
Diff to previous 5091
Promote arguments to Union operations.
Fix a typo.
Remove stringify since it is now the same as the parent class.

Revision 5091 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 30 00:28:32 2007 UTC (12 years, 7 months ago) by dpvc
File length: 9520 byte(s)
Diff to previous 5089
Handle canBeInUnion properly (it must come AFTER isSetOfReals, and
needs to deal with empty parens).

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: 9523 byte(s)
Diff to previous 5042
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 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: 9452 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, 7 months ago) by dpvc
File length: 9430 byte(s)
Diff to previous 5001
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 5001 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jun 12 04:05:56 2007 UTC (12 years, 8 months ago) by dpvc
File length: 9436 byte(s)
Diff to previous 4996
More fixes for creating items in the corret context.  Also added a
method for looking up the package associated with a particular Parser
class (for consistency with the Value->Package call).

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: 9452 byte(s)
Diff to previous 4993
Allow promote() to accept a context as the first argument so that the
promoted object can be forced into the given context.

Revision 4993 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 8 12:09:53 2007 UTC (12 years, 8 months ago) by dpvc
File length: 9357 byte(s)
Diff to previous 4992
Added more flexible type checking for MathObject classes.  This makes
it possible to correctly match types even when the context has
specified a different package to handle a given type, for example.

Revision 4992 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 8 11:05:48 2007 UTC (12 years, 8 months ago) by dpvc
File length: 9354 byte(s)
Diff to previous 4991
Fixed typo.

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: 9351 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: 9372 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: 9286 byte(s)
Diff to previous 4975
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 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: 9311 byte(s)
Diff to previous 3716
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 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: 9579 byte(s)
Diff to previous 3525
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 3525 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 14 00:23:10 2005 UTC (14 years, 6 months ago) by dpvc
File length: 9532 byte(s)
Diff to previous 3516
Added methods for testing containment of one set in another, and so
on.  These include:

     $A->contains($B)        Test if $B is a subset of $A (or an
                             element of $A if $B$ is a real number).

     $A->isSubsetOf($B)      Test if $A is a subset of $B.

     $A->isEmpty             True if $A is the empty set.

     $A->intersects($B)      True if $A and $B have numbers in common.

     $A->intersect($B)       The set of numbers common to both $A and $B.

Be careful of the difference between "intersect" and "intersects".
One is a set the other a true/false value.

Revision 3516 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 20:59:28 2005 UTC (14 years, 6 months ago) by dpvc
File length: 8864 byte(s)
Diff to previous 3514
Added isSetOfReals and canBeInUnion methods to the Value objects, and
replaced the ad hoc tests for these conditions to call these
routines.

Cleaned up the make() methods for Intervals, Sets and Unions, and
improved the new() methods to handle more cases better.

Fixed Value::makeValue() to handle an array reference correctly.

I don't THINK any of this will break anything.  :-)

Revision 3514 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 19:10:41 2005 UTC (14 years, 6 months ago) by dpvc
File length: 9160 byte(s)
Diff to previous 3512
Make sure the singletons are sorted before comparing them to the
intervals (and each other).

Revision 3512 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 18:19:01 2005 UTC (14 years, 6 months ago) by dpvc
File length: 9143 byte(s)
Diff to previous 3508
Can't use the length check when reducing unions, since it could
contain a single set that is not reduced, and we need to check that,
too.

Revision 3508 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 16:58:56 2005 UTC (14 years, 6 months ago) by dpvc
File length: 9185 byte(s)
Diff to previous 3505
Added isReduced method to tell if a Union, Set or Interval is already
reduced.  Fixed up sort to use CORE::sort, and added sort and reduce
to Intervals, which do nothing, but are there for consistency.

Revision 3505 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 16:33:50 2005 UTC (14 years, 6 months ago) by dpvc
File length: 8791 byte(s)
Diff to previous 3497
Added sort methods to Union and Set that return objects with their
data sorted.

Revision 3497 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 00:25:27 2005 UTC (14 years, 6 months ago) by dpvc
File length: 8531 byte(s)
Diff to previous 3477
Added ability for Unions and Sets to simplify themselves
(automatically or on demand), and added flags to the Context and
answer checkers to control these features.  The new Context flags
are

    reduceUnions                tells whether unions are automatically
                                reduced when they are created.

    reduceUnionsForComparison   tells whether unions are reduced
                                before comparing them for equality
                                or inequality (etc) if they aren't
                                reduced already.

    reduceSets                  tells whether redundent elements are
                                removed from sets as they are created.

    reduceSetsForComparison     tells whether sets are reduced before
                                comparing them.

All of these default to true.

The Interval, Set, Union, and List answer checkers not have two new
flags for controlling these values:

    studentsMustReduceUnions    tells whether unions and sets will be
                                counted as incorrect when they are not
                                reduced to non-overlapping intervals
                                and at most one set with no repeated
                                entries.

    showUnionReduceWarnings     tells whether an error message will
                                be produced for non-reduced unions and
                                sets, or if they will be marked wrong
                                silently.  (Not available in Lists.)

Both of these are true by default, since most professors probably want
their students to write intervals in reduced form.  (Is this true?)
This corresponds the the current behavior of the interval checkers,
which require the student's answer to be the same set of intervals as
in the professor's, but with the addition of an error message when the
student answer is not reduced.

Revision 3477 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 11 20:57:18 2005 UTC (14 years, 6 months ago) by dpvc
File length: 6799 byte(s)
Diff to previous 3472
Added ability to subtract intervals, sets and unions.  Adjusted the
precedence of the union 'U' to be above _ and + so that things like
(1,5) U (7,10) - {8} U (2,3) will do ((1,5) U (7,10)) - ({8} U (2,3))
rather than the previous (1,5) U ((7,10) - {8}) U (2,3).  Finally,
added a constant 'R' to the Interval context that is equivalent to
(-inf,inf), so you can do things like R-{0} now.

Still need to work out reducing unions so that things like (1,3)U(2,4)
can become (1,4).

Revision 3472 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 11 14:33:09 2005 UTC (14 years, 6 months ago) by dpvc
File length: 5502 byte(s)
Diff to previous 3369
Changes needed to Set object.  Also, use Parser to handle unions
defined as strings rather than doing it by hand (that's the whole
point, isn't it?).  Added object promotion from lower-precedence
classes (for better error messages), and fixed up the comparison
routine.

Revision 3369 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jul 12 21:05:37 2005 UTC (14 years, 7 months ago) by dpvc
File length: 4545 byte(s)
Diff to previous 3261
Fixed various perl compiler warnings (due to extra "my", and so on).

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: 4545 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: 4590 byte(s)
Diff to previous 2800
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 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: 4517 byte(s)
Diff to previous 2678
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 2678 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 23 23:55:37 2004 UTC (15 years, 5 months ago) by dpvc
File length: 4555 byte(s)
Diff to previous 2625
Modified the parser so that the classes for the various object
constructors are stored in the context table rather than hard-coded
into the parser.  That way, you can override the default classes with
your own.  This gives you even more complete control to modify the
parser.  (You had been able to replace the definitions of operators,
functions and list-like objects, but could not override the behaviour
of numbers, strings, variables, and so on.  Now you can.)

This effects most of the files, but only by changing the name of the
calls that create the various objects.

There are also a couple of other minor fixes.

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: 4529 byte(s)
Diff to previous 2612
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 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: 4526 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: 4550 byte(s)
Diff to previous 2601
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 2601 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 13 19:06:09 2004 UTC (15 years, 6 months ago) by dpvc
File length: 4567 byte(s)
Diff to previous 2594
Added ability to report incorrect coordinates in point and vector
answers, and incorrect endpoints and endpoint types in intervals.
Separated these kinds of checks from the typeMatch check, where they
didn't really belong.

Added ability to specify intervals and unions as strings in Interval()
and Union(), which makes it easier to make constants of these types.

There are still problems comparing intervals that contain infinities;
I really need to make the infinity object to solve this, so have put
off trying to fix that for now.

Revision 2594 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 12 20:17:18 2004 UTC (15 years, 6 months ago) by dpvc
File length: 4447 byte(s)
Diff to previous 2592
Fixes for handling intervals better.  In particular, deal better with
ambiguous situations, like (1,2) that could be a point.

You can use [a,a] to specify the single point a.  I'd like to make {a}
represent this (and maybe even {a,b,c} to form finite sets), but this
would interfere with the use of { and } as alternative parentheses.
(Does anyone really use these?)

Do we need a cross product for intervals (and sets) as a means of
representing regions in R^2 (or higher)?

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: 4397 byte(s)
Diff to previous 2579
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 2579 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 9 21:38:01 2004 UTC (15 years, 6 months ago) by dpvc
File length: 4293 byte(s)
Diff to previous 2558
Significant update to new parser.

New features include:

  Better control over format of vector output (you can now
    specify ijk-format rather than <...> format)

  "Fuzzy" reals, where the relations like == return true when the
    two values are "close enough".  (This is controlable using
    parameters similar to those used in NUM_CMP).

  The fuzzy reals are now used in vectors/points/matrices/complexes/intervals
    and so on so that their relations will also be fuzzy.  E.g.,
    (1E-13,2) == (0,3) will be true, and norm(Vector(0,1E-13)) will
    equal 0.

  The two main portions of the parser (the Parser and Value packages)
    now share a common context object for configuration purposes.

Revision 2558 - (view) (download) (as text) (annotate) - [select for diffs]
Added Wed Jul 28 20:32:33 2004 UTC (15 years, 6 months ago) by sh002i
File length: 4291 byte(s)
merged changes from rel-2-1-a1 -- stop using that branch.

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