1 //=================================================================================================
2 /*!
3 //  \file blaze/math/typetraits/IsColumns.h
4 //  \brief Header file for the IsColumns type trait
5 //
6 //  Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
7 //
8 //  This file is part of the Blaze library. You can redistribute it and/or modify it under
9 //  the terms of the New (Revised) BSD License. Redistribution and use in source and binary
10 //  forms, with or without modification, are permitted provided that the following conditions
11 //  are met:
12 //
13 //  1. Redistributions of source code must retain the above copyright notice, this list of
14 //     conditions and the following disclaimer.
15 //  2. Redistributions in binary form must reproduce the above copyright notice, this list
16 //     of conditions and the following disclaimer in the documentation and/or other materials
17 //     provided with the distribution.
18 //  3. Neither the names of the Blaze development group nor the names of its contributors
19 //     may be used to endorse or promote products derived from this software without specific
20 //     prior written permission.
21 //
22 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23 //  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 //  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 //  SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 //  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 //  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 //  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 //  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 //  DAMAGE.
32 */
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TYPETRAITS_ISCOLUMNS_H_
36 #define _BLAZE_MATH_TYPETRAITS_ISCOLUMNS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/views/Forward.h>
44 #include <blaze/util/IntegralConstant.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 //  CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
56 /*!\brief Compile time check for column selections.
57 // \ingroup math_type_traits
58 //
59 // This type trait tests whether or not the given template parameter is a column selection (i.e. a
60 // view on columns of a dense or sparse matrix). In case the type is a column selection, the \a value
61 // member constant is set to \a true, the nested type definition \a Type is \a TrueType, and the
62 // class derives from \a TrueType. Otherwise \a value is set to \a false, \a Type is \a FalseType,
63 // and the class derives from \a FalseType.
64 
65    \code
66    using blaze::aligned;
67 
68    using MatrixType1 = blaze::StaticMatrix<int,10UL,16UL>;
69    using MatrixType2 = blaze::DynamicMatrix<double>;
70    using MatrixType3 = blaze::CompressedMatrix<float>;
71 
72    MatrixType1 A;
73    MatrixType2 B( 100UL, 200UL );
74    MatrixType3 C( 200UL, 250UL );
75 
76    using ColumnsType1 = decltype( blaze::columns<2UL,4UL>( A ) );
77    using ColumnsType2 = decltype( blaze::columns( B, 8UL, 24UL ) );
78    using ColumnsType3 = decltype( blaze::columns( C, 5UL, 13UL ) );
79 
80    blaze::IsColumns< ColumnsType1 >::value       // Evaluates to 1
81    blaze::IsColumns< const ColumnsType2 >::Type  // Results in TrueType
82    blaze::IsColumns< volatile ColumnsType3 >     // Is derived from TrueType
83    blaze::IsColumns< MatrixType1 >::value        // Evaluates to 0
84    blaze::IsColumns< const MatrixType2 >::Type   // Results in FalseType
85    blaze::IsColumns< volatile MatrixType3 >      // Is derived from FalseType
86    \endcode
87 */
88 template< typename T >
89 struct IsColumns
90    : public FalseType
91 {};
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
96 /*! \cond BLAZE_INTERNAL */
97 /*!\brief Specialization of the IsColumns type trait for 'Columns'.
98 // \ingroup math_type_traits
99 */
100 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
101 struct IsColumns< Columns<MT,SO,DF,SF,CRAs...> >
102    : public TrueType
103 {};
104 /*! \endcond */
105 //*************************************************************************************************
106 
107 
108 //*************************************************************************************************
109 /*! \cond BLAZE_INTERNAL */
110 /*!\brief Specialization of the IsColumns type trait for 'const Columns'.
111 // \ingroup math_type_traits
112 */
113 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
114 struct IsColumns< const Columns<MT,SO,DF,SF,CRAs...> >
115    : public TrueType
116 {};
117 /*! \endcond */
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
122 /*! \cond BLAZE_INTERNAL */
123 /*!\brief Specialization of the IsColumns type trait for 'volatile Columns'.
124 // \ingroup math_type_traits
125 */
126 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
127 struct IsColumns< volatile Columns<MT,SO,DF,SF,CRAs...> >
128    : public TrueType
129 {};
130 /*! \endcond */
131 //*************************************************************************************************
132 
133 
134 //*************************************************************************************************
135 /*! \cond BLAZE_INTERNAL */
136 /*!\brief Specialization of the IsColumns type trait for 'const volatile Columns'.
137 // \ingroup math_type_traits
138 */
139 template< typename MT, bool SO, bool DF, bool SF, typename... CRAs >
140 struct IsColumns< const volatile Columns<MT,SO,DF,SF,CRAs...> >
141    : public TrueType
142 {};
143 /*! \endcond */
144 //*************************************************************************************************
145 
146 
147 //*************************************************************************************************
148 /*!\brief Auxiliary variable template for the IsColumns type trait.
149 // \ingroup math_type_traits
150 //
151 // The IsColumns_v variable template provides a convenient shortcut to access the nested \a value
152 // of the IsColumns class template. For instance, given the type \a T the following two statements
153 // are identical:
154 
155    \code
156    constexpr bool value1 = blaze::IsColumns<T>::value;
157    constexpr bool value2 = blaze::IsColumns_v<T>;
158    \endcode
159 */
160 template< typename T >
161 constexpr bool IsColumns_v = IsColumns<T>::value;
162 //*************************************************************************************************
163 
164 } // namespace blaze
165 
166 #endif
167