00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef TNT_FORTRAN_ARRAY2D_UTILS_H
00022 #define TNT_FORTRAN_ARRAY2D_UTILS_H
00023 
00024 #include <iostream>
00025 
00026 namespace TNT
00027 {
00028 
00029 
00037 template <class T>
00038 std::ostream& operator<<(std::ostream &s, const Fortran_Array2D<T> &A)
00039 {
00040     int M=A.dim1();
00041     int N=A.dim2();
00042 
00043     s << M << " " << N << "\n";
00044 
00045     for (int i=1; i<=M; i++)
00046     {
00047         for (int j=1; j<=N; j++)
00048         {
00049             s << A(i,j) << " ";
00050         }
00051         s << "\n";
00052     }
00053 
00054 
00055     return s;
00056 }
00057 
00074 template <class T>
00075 std::istream& operator>>(std::istream &s, Fortran_Array2D<T> &A)
00076 {
00077 
00078     int M, N;
00079 
00080     s >> M >> N;
00081 
00082         Fortran_Array2D<T> B(M,N);
00083 
00084     for (int i=1; i<=M; i++)
00085         for (int j=1; j<=N; j++)
00086         {
00087             s >>  B(i,j);
00088         }
00089 
00090         A = B;
00091     return s;
00092 }
00093 
00094 
00095 
00096 
00097 } 
00098 
00099 #endif