tensor-0.1.0
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
tensor_reshape_z.cc
1 // -*- mode: c++; fill-column: 80; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 /*
3  Copyright (c) 2010 Juan Jose Garcia Ripoll
4 
5  Tensor is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published
7  by the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Library General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #include <tensor/tensor.h>
21 
22 namespace tensor {
23 
25  const CTensor reshape(const CTensor &t, const Indices &new_dims)
26  {
27  return CTensor(new_dims, t);
28  }
29 
31  const CTensor reshape(const CTensor &t, index length)
32  {
33  Indices new_dims(1);
34  new_dims.at(0) = length;
35  return CTensor(new_dims, t);
36  }
37 
39  const CTensor reshape(const CTensor &t, index rows, index cols)
40  {
41  Indices new_dims(2);
42  new_dims.at(0) = rows;
43  new_dims.at(1) = cols;
44  return CTensor(new_dims, t);
45  }
46 
48  const CTensor reshape(const CTensor &t, index d1, index d2, index d3)
49  {
50  Indices new_dims(3);
51  new_dims.at(0) = d1;
52  new_dims.at(1) = d2;
53  new_dims.at(2) = d3;
54  return CTensor(new_dims, t);
55  }
56 
58  const CTensor reshape(const CTensor &t, index d1, index d2, index d3,
59  index d4)
60  {
61  Indices new_dims(4);
62  new_dims.at(0) = d1;
63  new_dims.at(1) = d2;
64  new_dims.at(2) = d3;
65  new_dims.at(3) = d4;
66  return CTensor(new_dims, t);
67  }
68 
70  const CTensor reshape(const CTensor &t, index d1, index d2, index d3,
71  index d4, index d5)
72  {
73  Indices new_dims(5);
74  new_dims.at(0) = d1;
75  new_dims.at(1) = d2;
76  new_dims.at(2) = d3;
77  new_dims.at(3) = d4;
78  new_dims.at(4) = d5;
79  return CTensor(new_dims, t);
80  }
81 
83  const CTensor reshape(const CTensor &t, index d1, index d2, index d3,
84  index d4, index d5, index d6)
85  {
86  Indices new_dims(6);
87  new_dims.at(0) = d1;
88  new_dims.at(1) = d2;
89  new_dims.at(2) = d3;
90  new_dims.at(3) = d4;
91  new_dims.at(4) = d5;
92  new_dims.at(5) = d6;
93  return CTensor(new_dims, t);
94  }
95 
96 } // namespace tensor
97 
Complex Tensor with elements of type "cdouble".
Definition: tensor.h:435
const RTensor reshape(const RTensor &t, const Indices &new_dims)
Return a RTensor with same data and given dimensions.
Vector of 'index' type, where 'index' fits the indices of a tensor.
Definition: indices.h:35