toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN TooN.h doc/documentation.h test/identity_t...


From: Edward Rosten
Subject: [Toon-members] TooN TooN.h doc/documentation.h test/identity_t...
Date: Thu, 18 Jun 2009 14:52:49 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/06/18 14:52:49

Modified files:
        .              : TooN.h 
        doc            : documentation.h 
        test           : identity_test.cc vec_test.cc 

Log message:
        Reinstated a form of the , operator for filling:
        
        Matrix<2> m;
        Fill(m) = 1, 2,
                  3, 4;
        
        Underfilling is detected at run-time only.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/TooN.h?cvsroot=toon&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/TooN/doc/documentation.h?cvsroot=toon&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/TooN/test/identity_test.cc?cvsroot=toon&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/TooN/test/vec_test.cc?cvsroot=toon&r1=1.4&r2=1.5

Patches:
Index: TooN.h
===================================================================
RCS file: /cvsroot/toon/TooN/TooN.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- TooN.h      9 Jun 2009 13:33:22 -0000       1.44
+++ TooN.h      18 Jun 2009 14:52:49 -0000      1.45
@@ -54,7 +54,11 @@
                struct StaticSliceError{};
                struct SizeMismatch{};
                struct StaticSizeMismatch{};
-
+               struct VectorOverfill{};
+               struct StaticVectorOverfill{};
+               struct MatrixOverfill{};
+               struct StaticMatrixOverfill{};
+               struct Underfill{};
        }
 #endif
        
@@ -178,9 +182,12 @@
 #include <TooN/internal/allocator.hh>
 
 #include <TooN/internal/size_mismatch.hh>
+#include <TooN/internal/overfill_error.hh>
 #include <TooN/internal/slice_error.hh>
 #include <TooN/internal/debug.hh>
 
+#include <TooN/internal/comma.hh>
+
 #include <TooN/internal/vbase.hh>
 #include <TooN/internal/vector.hh>
        

Index: doc/documentation.h
===================================================================
RCS file: /cvsroot/toon/TooN/doc/documentation.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- doc/documentation.h 9 Jun 2009 13:33:23 -0000       1.26
+++ doc/documentation.h 18 Jun 2009 14:52:49 -0000      1.27
@@ -244,6 +244,19 @@
                @endcode
                note that you need to specify the size in the dynamic case.
 
+               A less general, but visually more pleasing syntax can also be 
used:
+               @code
+                       Vector<5> v;
+                       Fill(v) v = 1,2,3,4,5; 
+
+                       Matrix<3,3> m;
+                       Fill(m) = 1, 2, 3, 
+                                 4, 5, 6, 
+                                         7, 8, 9;
+               @endcode
+               Note that underfilling is a run-time check, since it can not be 
detected
+               at compile time.
+
                They can also be initialized with data from another source. See 
also \ref  sWrap.
 
 
@@ -285,13 +298,25 @@
        \subsection sDebug What debugging options are there?
 
        By default, everything which is checked at compile time in the static 
case
-       is checked at run-time in the dynamic case. In other words, slices and 
sizes
-       are checked at run-time if need be. These checks can be disabled by 
defining
-       the macros \c TOON_NDEBUG_SLICE and \c TOON_NDEBUG_SIZE respectively. 
Bounds are
+       is checked at run-time in the dynamic case (with some additions). 
Checks can
+       be disabled with various macros. Note that the optimizer will usually
+       remove run-time checks on static objects if the test passes.
+       - Slices
+               - Disable with \c TOON_NDEBUG_SLICE
+       - Sizes
+               - Disable with \c TOON_NDEBUG_SIZE
+       - overfilling using Fill 
+               - Disable with \c TOON_NDEBUG_FILL
+       - underfilling using Fill (run-time check)
+               - Disable with \c TOON_NDEBUG_FILL
+       
+       Bounds are
        not checked by default. Bounds checking can be enabled by defining the 
macro
        \c TOON_CHECK_BOUNDS. None of these macros change the interface, so 
debugging
        code can be freely mixed with optimized code.
 
+
+
        Errors are manifested to a call to <code>std::abort()</code>.
 
        TooN does not initialize data in a Vector or Matrix.  For debugging 
purposes

Index: test/identity_test.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/identity_test.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- test/identity_test.cc       11 Jun 2009 20:53:19 -0000      1.4
+++ test/identity_test.cc       18 Jun 2009 14:52:49 -0000      1.5
@@ -21,7 +21,7 @@
        Matrix<> q = 5.5 * Identity(6) * 2;
 
        cout << q << endl;
-       cout << q - 3*Identity/4 << endl;
+       cout << q - 3.*Identity/4 << endl;
 
        Matrix<3> p = Ones * 2;
 

Index: test/vec_test.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/vec_test.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- test/vec_test.cc    11 Feb 2009 18:04:25 -0000      1.4
+++ test/vec_test.cc    18 Jun 2009 14:52:49 -0000      1.5
@@ -150,6 +150,48 @@
 
 
 
+#define test_comma(...) test_comma_(__LINE__, __VA_ARGS__)
+template<class C> void test_comma_(int func_lineno)
+{
+       TRY{
+               Vector<4> v;
+               Fill(v) = 1,2,3,4;
+       }
+       EXPECT(NoError);
+
+       TRY{
+               Vector<4> v(4);
+               Fill(v) = 1,2,3,4;
+       }
+       EXPECT(NoError);
+
+       TRY{
+               Vector<4> v;
+               Fill(v) = 1,2,3,4,5;
+       }
+       EXPECT(StaticVectorOverfill);
+
+       TRY{
+               Vector<> v(4);
+               Fill(v) = 1,2,3,4,5;
+       }
+       EXPECT(VectorOverfill);
+
+       TRY{
+               Vector<4> v;
+               Fill(v) = 1,2,3;
+       }
+       EXPECT(Underfill);
+
+       TRY{
+               Vector<> v(4);
+               Fill(v) = 1,2,3;
+       }
+       EXPECT(Underfill);
+}
+
+
+
 int main()
 {
        test_static_static_slices(Vector<2>());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]