[PATCH] Fix TinyMatrix print inconsistency

Jeffrey D. Oldham oldham at codesourcery.com
Tue May 25 18:21:47 UTC 2004


Richard Guenther wrote:

> Jeffrey D. Oldham wrote:
>
>> Richard Guenther wrote:
>>
>>> On Fri, 21 May 2004, Radek Pecher wrote:
>>>
>>>  
>>>
>>>> - although Tensor.h:338 claims:
>>>> // The format is: ((t(0,0) t(1,0),... ) ( t(0,1) t(1,1) ... ) ... ))
>>>>  the truth is in fact:
>>>> // The format is: ((t(0,0) t(0,1),... ) ( t(1,0) t(1,1) ... ) ... ))
>>>> - this is contrary to TinyMatrix because of the i,j-swapping
>>>>  (compare: Tensor.h:361 and TinyMatrix.h:236)
>>>>   
>>>
>>>
>>>
>>> That is indeed inconsistent(?).  I don't know what to do on this 
>>> one, but
>>> it seems purely cosmetic.  I'd suggest fixing the comments and not swap
>>> the indices in TinyMatrix.h:239.  Jeffrey?
>>>  
>>>
>>
>> I agree that consistency is important.  Which particular ordering to 
>> choose is not important to me.  Arrays print out in the actual order 
>> (0,0), (0,1), etc. so I think tensors should also.  The commented 
>> tensor ordering probably follows from the comments concerning the 
>> three types of tensors and wishing to print those values.
>
>
> That would be the following patch. Tested with Tiny tests, ok?
>
> Richard.
>
> 2004May25  Richard Guenther <richard.guenther at uni-tuebingen.de>
>
>     * src/Tiny/Tensor.h: fix comments describing output format.
>     src/Tiny/TinyMatrix.h: fix comments describing output format,
>     fix output format to match the one of tensors.
>

This is good.  It must be correct since the indices are now "i,j", not 
"j,i". ;)

Thanks for the work.  Yes, let's commit this improvement.

>------------------------------------------------------------------------
>
>Index: Tiny/Tensor.h
>===================================================================
>RCS file: /home/pooma/Repository/r2/src/Tiny/Tensor.h,v
>retrieving revision 1.46
>diff -u -u -r1.46 Tensor.h
>--- Tiny/Tensor.h	21 Oct 2003 19:50:04 -0000	1.46
>+++ Tiny/Tensor.h	25 May 2004 18:08:09 -0000
>@@ -337,7 +337,7 @@
> 
> 
>   // Output to a stream.
>-  // The format is: ((t(0,0) t(1,0),... ) ( t(0,1) t(1,1) ... ) ... ))
>+  // The format is: ((t(0,0) t(0,1),... ) ( t(1,0) t(1,1) ... ) ... ))
> 
>   template<class Out>
>   void print(Out &out) const
>@@ -379,7 +379,7 @@
> 
> 
> /// Output to a stream.
>-/// The format is: ( ( t(0,0) t(1,0),... ) ( t(0,1) t(1,1) ... ) ... )
>+/// The format is: ( ( t(0,0) t(0,1),... ) ( t(1,0) t(1,1) ... ) ... )
> 
> template<int D, class T, class E>
> std::ostream &operator<<(std::ostream &out, const Tensor<D,T,E> &t)
>Index: Tiny/TinyMatrix.h
>===================================================================
>RCS file: /home/pooma/Repository/r2/src/Tiny/TinyMatrix.h,v
>retrieving revision 1.16
>diff -u -u -r1.16 TinyMatrix.h
>--- Tiny/TinyMatrix.h	21 Oct 2003 19:50:04 -0000	1.16
>+++ Tiny/TinyMatrix.h	25 May 2004 18:08:09 -0000
>@@ -213,7 +213,7 @@
> 
> 
>   // Output to a stream.
>-  // The format is: ((t(0,0) t(1,0),... ) (t(0,1) t(1,1) ... ) ... ))
>+  // The format is: ((t(0,0) t(0,1),... ) (t(1,0) t(1,1) ... ) ... ))
> 
>   template<class Out>
>   void print(Out &out) const
>@@ -225,18 +225,18 @@
>     long precision = out.precision();
>     out.width(0);
>     out << "(";
>-    for (int i = 0; i < D2; i++) {
>+    for (int i = 0; i < D1; i++) {
>       out << "(";
>       out.flags(incomingFormatFlags);
>       out.width(width);
>       out.precision(precision);
>-      out << (*this)(0, i);
>-      for (int j = 1; j < D1; j++) {
>+      out << (*this)(i, 0);
>+      for (int j = 1; j < D2; j++) {
>         out << " ";
>         out.flags(incomingFormatFlags);
>         out.width(width);
>         out.precision(precision);
>-        out << (*this)(j, i);
>+        out << (*this)(i, j);
>       }
>       out << ")";
>     }
>@@ -255,7 +255,7 @@
> 
> 
> /// Output to a stream.
>-/// The format is: ( ( t(0,0) t(1,0),... ) ( t(0,1) t(1,1) ... ) ... )
>+/// The format is: ( ( t(0,0) t(0,1),... ) ( t(1,0) t(1,1) ... ) ... )
> 
> template<int D1, int D2, class T, class E>
> std::ostream &operator<<(std::ostream &out, const TinyMatrix<D1,D2,T,E> &t)
>  
>


-- 
Jeffrey D. Oldham
oldham at codesourcery.com





More information about the pooma-dev mailing list