ivl 679
ivl/details/mfunc/grid.hpp
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>.
00002    A C++ template library extending syntax towards mathematical notation.
00003 
00004    Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr>
00005    Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr>
00006 
00007    ivl is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU Lesser General Public License 
00009    version 3 as published by the Free Software Foundation.
00010 
00011    Alternatively, you can redistribute it and/or modify it under the terms 
00012    of the GNU General Public License version 2 as published by the Free 
00013    Software Foundation.
00014 
00015    ivl is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00018    See the GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License 
00021    and a copy of the GNU Lesser General Public License along 
00022    with ivl. If not, see <http://www.gnu.org/licenses/>. */
00023 
00024 
00025 #ifndef IVL_MFUNC_GRID
00026 #define IVL_MFUNC_GRID
00027 
00028 namespace ivl {
00029 
00030 static __attribute__((unused))
00031 struct grid_impl : public ivl_func<grid_impl>
00032 {
00033         template<class T, class S1, class S2, class I1, class I2>
00034         void operate(array_2d<T, S1>& yy, array_2d<T, S2>& xx, sep,
00035                                 const array<T, I1>& y, const array<T, I2>& x)
00036         {
00037                 xx = mtimes(ones<T>(y.length(), 1), array_2d<T>(1, x.length(), x));
00038                 yy = mtimes(array_2d<T>(y.length(), 1, y), ones<T>(1, x.length()));
00039         }
00040         // TODO: make a global decision...
00041         template<class T, class T0, class T1, class T2,
00042                 class S1, class S2, class I1, class I2>
00043         void operate(array_nd<T, S1>& yy, array_nd<T0, S2>& xx, sep,
00044                                 const array<T1, I1>& y, const array<T2, I2>& x)
00045         {
00046                 xx = mtimes(ones<T>(y.length(), 1), array_2d<T>(1, x.length(), x));
00047                 yy = mtimes(array_2d<T>(y.length(), 1, y), ones<T>(1, x.length()));
00048         }
00049 
00050         template<class T, class I1, class I2>
00051         ret<array_2d<T>, array_2d<T> > operator()(
00052                                 const array<T, I1>& y, const array<T, I2>& x)
00053         {
00054                 ret<array_2d<T> > xx, yy;
00055                 xx = mtimes(ones<T>(y.length(), 1), array_2d<T>(1, x.length(), x));
00056                 yy = mtimes(array_2d<T>(y.length(), 1, y), ones<T>(1, x.length()));
00057                 return (_, yy, xx);
00058         }
00059 
00060 } grid;
00061 
00062 } /* namespace ivl */
00063 
00064 #endif // IVL_MFUNC_GRID
 All Classes Namespaces Files Functions Variables Typedefs Enumerations