| [221] | 1 | /*************************************************************************** | 
|---|
|  | 2 | * blitz/array/slice.h    Helper classes for slicing arrays | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * $Id: slice.h,v 1.1.1.1 1999-04-09 17:59:04 ansari Exp $ | 
|---|
|  | 5 | * | 
|---|
|  | 6 | * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca> | 
|---|
|  | 7 | * | 
|---|
|  | 8 | * This program is free software; you can redistribute it and/or | 
|---|
|  | 9 | * modify it under the terms of the GNU General Public License | 
|---|
|  | 10 | * as published by the Free Software Foundation; either version 2 | 
|---|
|  | 11 | * of the License, or (at your option) any later version. | 
|---|
|  | 12 | * | 
|---|
|  | 13 | * This program is distributed in the hope that it will be useful, | 
|---|
|  | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 16 | * GNU General Public License for more details. | 
|---|
|  | 17 | * | 
|---|
|  | 18 | * Suggestions:          blitz-suggest@cybervision.com | 
|---|
|  | 19 | * Bugs:                 blitz-bugs@cybervision.com | 
|---|
|  | 20 | * | 
|---|
|  | 21 | * For more information, please see the Blitz++ Home Page: | 
|---|
|  | 22 | *    http://seurat.uwaterloo.ca/blitz/ | 
|---|
|  | 23 | * | 
|---|
|  | 24 | *************************************************************************** | 
|---|
|  | 25 | * $Log: not supported by cvs2svn $ | 
|---|
|  | 26 | * Revision 1.2  1998/03/14 00:04:47  tveldhui | 
|---|
|  | 27 | * 0.2-alpha-05 | 
|---|
|  | 28 | * | 
|---|
|  | 29 | * Revision 1.1  1997/07/16 14:51:20  tveldhui | 
|---|
|  | 30 | * Update: Alpha release 0.2 (Arrays) | 
|---|
|  | 31 | * | 
|---|
|  | 32 | */ | 
|---|
|  | 33 |  | 
|---|
|  | 34 | #ifndef BZ_ARRAYSLICE_H | 
|---|
|  | 35 | #define BZ_ARRAYSLICE_H | 
|---|
|  | 36 |  | 
|---|
|  | 37 | #ifndef BZ_ARRAY_H | 
|---|
|  | 38 | #error <blitz/array/slice.h> must be included via <blitz/array.h> | 
|---|
|  | 39 | #endif | 
|---|
|  | 40 |  | 
|---|
|  | 41 | BZ_NAMESPACE(blitz) | 
|---|
|  | 42 |  | 
|---|
|  | 43 | // Forward declaration | 
|---|
|  | 44 | template<class T, int N> | 
|---|
|  | 45 | class Array; | 
|---|
|  | 46 |  | 
|---|
|  | 47 |  | 
|---|
|  | 48 |  | 
|---|
|  | 49 | class nilArraySection { }; | 
|---|
|  | 50 |  | 
|---|
|  | 51 | template<class T> | 
|---|
|  | 52 | class ArraySectionInfo { | 
|---|
|  | 53 | public: | 
|---|
|  | 54 | enum { isValidType = 0, rank = 0, isPick = 0 }; | 
|---|
|  | 55 | }; | 
|---|
|  | 56 |  | 
|---|
|  | 57 | template<> | 
|---|
|  | 58 | class ArraySectionInfo<Range> { | 
|---|
|  | 59 | public: | 
|---|
|  | 60 | enum { isValidType = 1, rank = 1, isPick = 0 }; | 
|---|
|  | 61 | }; | 
|---|
|  | 62 |  | 
|---|
|  | 63 | template<> | 
|---|
|  | 64 | class ArraySectionInfo<int> { | 
|---|
|  | 65 | public: | 
|---|
|  | 66 | enum { isValidType = 1, rank = 0, isPick = 0 }; | 
|---|
|  | 67 | }; | 
|---|
|  | 68 |  | 
|---|
|  | 69 | template<> | 
|---|
|  | 70 | class ArraySectionInfo<nilArraySection> { | 
|---|
|  | 71 | public: | 
|---|
|  | 72 | enum { isValidType = 1, rank = 0, isPick = 0 }; | 
|---|
|  | 73 | }; | 
|---|
|  | 74 |  | 
|---|
|  | 75 | template<class T_numtype, class T1, class T2 = nilArraySection, | 
|---|
|  | 76 | class T3 = nilArraySection, class T4 = nilArraySection, | 
|---|
|  | 77 | class T5 = nilArraySection, class T6 = nilArraySection, | 
|---|
|  | 78 | class T7 = nilArraySection, class T8 = nilArraySection, | 
|---|
|  | 79 | class T9 = nilArraySection, class T10 = nilArraySection, | 
|---|
|  | 80 | class T11 = nilArraySection> | 
|---|
|  | 81 | class SliceInfo { | 
|---|
|  | 82 | public: | 
|---|
|  | 83 | enum { | 
|---|
|  | 84 | numValidTypes = ArraySectionInfo<T1>::isValidType | 
|---|
|  | 85 | + ArraySectionInfo<T2>::isValidType | 
|---|
|  | 86 | + ArraySectionInfo<T3>::isValidType | 
|---|
|  | 87 | + ArraySectionInfo<T4>::isValidType | 
|---|
|  | 88 | + ArraySectionInfo<T5>::isValidType | 
|---|
|  | 89 | + ArraySectionInfo<T6>::isValidType | 
|---|
|  | 90 | + ArraySectionInfo<T7>::isValidType | 
|---|
|  | 91 | + ArraySectionInfo<T8>::isValidType | 
|---|
|  | 92 | + ArraySectionInfo<T9>::isValidType | 
|---|
|  | 93 | + ArraySectionInfo<T10>::isValidType | 
|---|
|  | 94 | + ArraySectionInfo<T11>::isValidType, | 
|---|
|  | 95 |  | 
|---|
|  | 96 | rank          = ArraySectionInfo<T1>::rank | 
|---|
|  | 97 | + ArraySectionInfo<T2>::rank | 
|---|
|  | 98 | + ArraySectionInfo<T3>::rank | 
|---|
|  | 99 | + ArraySectionInfo<T4>::rank | 
|---|
|  | 100 | + ArraySectionInfo<T5>::rank | 
|---|
|  | 101 | + ArraySectionInfo<T6>::rank | 
|---|
|  | 102 | + ArraySectionInfo<T7>::rank | 
|---|
|  | 103 | + ArraySectionInfo<T8>::rank | 
|---|
|  | 104 | + ArraySectionInfo<T9>::rank | 
|---|
|  | 105 | + ArraySectionInfo<T10>::rank | 
|---|
|  | 106 | + ArraySectionInfo<T11>::rank, | 
|---|
|  | 107 |  | 
|---|
|  | 108 | isPick        = ArraySectionInfo<T1>::isPick | 
|---|
|  | 109 | + ArraySectionInfo<T2>::isPick | 
|---|
|  | 110 | + ArraySectionInfo<T3>::isPick | 
|---|
|  | 111 | + ArraySectionInfo<T4>::isPick | 
|---|
|  | 112 | + ArraySectionInfo<T5>::isPick | 
|---|
|  | 113 | + ArraySectionInfo<T6>::isPick | 
|---|
|  | 114 | + ArraySectionInfo<T7>::isPick | 
|---|
|  | 115 | + ArraySectionInfo<T8>::isPick | 
|---|
|  | 116 | + ArraySectionInfo<T9>::isPick | 
|---|
|  | 117 | + ArraySectionInfo<T10>::isPick | 
|---|
|  | 118 | + ArraySectionInfo<T11>::isPick | 
|---|
|  | 119 | }; | 
|---|
|  | 120 |  | 
|---|
|  | 121 | typedef Array<T_numtype,numValidTypes> T_array; | 
|---|
|  | 122 | typedef Array<T_numtype,rank> T_slice; | 
|---|
|  | 123 | }; | 
|---|
|  | 124 |  | 
|---|
|  | 125 | BZ_NAMESPACE_END | 
|---|
|  | 126 |  | 
|---|
|  | 127 | #endif // BZ_ARRAYSLICE_H | 
|---|