ivl 679
ivl/details/array_2d/functions/array_2d_core_functions.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 #ifndef IVL_ARRAY_2D_DETAILS_ARRAY_2D_CORE_FUNCTIONS_HPP
00025 #define IVL_ARRAY_2D_DETAILS_ARRAY_2D_CORE_FUNCTIONS_HPP
00026 
00027 
00028 namespace ivl {
00029 
00030 template <class T, class S>
00031 inline
00032 array_2d<T> row(const array<T, S>& a)
00033 {
00034         return array_2d<T>(1, a.length(), a);
00035 }
00036 
00037 template <class T, class S>
00038 inline
00039 array_2d<T> col(const array<T, S>& a)
00040 {
00041         return array_nd<T>(a.length(), 1, a);
00042 }
00043 
00044 template <class T>
00045 inline
00046 array_2d<T, data::fixed<1> > cell(const T& t)
00047 {
00048         return array_2d<T>(1, 1, t);
00049 }
00050 
00051 template <class T, class T1>
00052 inline
00053 array_2d<T, data::fixed<2> > row(const T& t0, const T1 & t1)
00054 {
00055         array_2d<T> a(1, 2);
00056         a[0] = t0; a[1] = t1;
00057         return a;
00058 }
00059 
00060 template <class T, class T1, class T2>
00061 inline
00062 array_2d<T, data::fixed<3> > row(const T& t0, const T1 & t1, const T2 & t2)
00063 {
00064         array_2d<T> a(1, 3);
00065         a[0] = t0; a[1] = t1; a[2] = t2;
00066         return a;
00067 }
00068 
00069 template <class T, class T1, class T2, class T3>
00070 inline
00071 array_2d<T, data::fixed<4> > row(const T& t0, const T1 & t1, const T2 & t2, const T3 & t3)
00072 {
00073         array_2d<T> a(1, 4);
00074         a[0] = t0; a[1] = t1; a[2] = t2; a[3] = t3;
00075         return a;
00076 }
00077 
00078 template <class T, class T1>
00079 inline
00080 array_2d<T, data::fixed<2> > col(const T& t0, const T1 & t1)
00081 {
00082         array_2d<T> a(2, 1);
00083         a[0] = t0; a[1] = t1;
00084         return a;
00085 }
00086 
00087 template <class T, class T1, class T2>
00088 inline
00089 array_2d<T, data::fixed<3> > col(const T& t0, const T1 & t1, const T2 & t2)
00090 {
00091         array_2d<T> a(3, 1);
00092         a[0] = t0; a[1] = t1; a[2] = t2;
00093         return a;
00094 }
00095 
00096 template <class T, class T1, class T2, class T3>
00097 inline
00098 array_2d<T, data::fixed<4> > col(const T& t0, const T1 & t1, const T2 & t2, const T3 & t3)
00099 {
00100         array_2d<T> a(4, 1);
00101         a[0] = t0; a[1] = t1; a[2] = t2; a[3] = t3;
00102         return a;
00103 }
00104 
00105 
00106 
00107 } /* namespace ivl */
00108 
00109 #endif // IVL_ARRAY_2D_DETAILS_ARRAY_2D_CORE_FUNCTIONS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations