@@ -109,12 +109,13 @@ public class NDArray<T, D : Dimension> constructor(
109109
110110 // TODO(get rid of copying)
111111 val newData = if (consistent) this .data else this .deepCopy().data
112- val newBase = if (consistent) base ? : this else null
112+ val newBase = if (consistent) this .base ? : this else null
113+ val newOffset = if (consistent) this .offset else 0
113114
114115 return if (this .dim.d == 1 && this .shape.first() == dim1) {
115116 this as D1Array <T >
116117 } else {
117- D1Array (newData, this .offset , intArrayOf(dim1), dim = D1 , base = newBase)
118+ D1Array (newData, newOffset , intArrayOf(dim1), dim = D1 , base = newBase)
118119 }
119120 }
120121
@@ -125,12 +126,13 @@ public class NDArray<T, D : Dimension> constructor(
125126
126127 // TODO(get rid of copying)
127128 val newData = if (consistent) this .data else this .deepCopy().data
128- val newBase = if (consistent) base ? : this else null
129+ val newBase = if (consistent) this .base ? : this else null
130+ val newOffset = if (consistent) this .offset else 0
129131
130132 return if (this .shape.contentEquals(newShape)) {
131133 this as D2Array <T >
132134 } else {
133- D2Array (newData, this .offset , newShape, dim = D2 , base = newBase)
135+ D2Array (newData, newOffset , newShape, dim = D2 , base = newBase)
134136 }
135137 }
136138
@@ -142,11 +144,12 @@ public class NDArray<T, D : Dimension> constructor(
142144 // TODO(get rid of copying)
143145 val newData = if (consistent) this .data else this .deepCopy().data
144146 val newBase = if (consistent) base ? : this else null
147+ val newOffset = if (consistent) this .offset else 0
145148
146149 return if (this .shape.contentEquals(newShape)) {
147150 this as D3Array <T >
148151 } else {
149- D3Array (newData, this .offset , newShape, dim = D3 , base = newBase)
152+ D3Array (newData, newOffset , newShape, dim = D3 , base = newBase)
150153 }
151154 }
152155
@@ -157,12 +160,13 @@ public class NDArray<T, D : Dimension> constructor(
157160
158161 // TODO(get rid of copying)
159162 val newData = if (consistent) this .data else this .deepCopy().data
160- val newBase = if (consistent) base ? : this else null
163+ val newBase = if (consistent) this .base ? : this else null
164+ val newOffset = if (consistent) this .offset else 0
161165
162166 return if (this .shape.contentEquals(newShape)) {
163167 this as D4Array <T >
164168 } else {
165- D4Array (newData, this .offset , newShape, dim = D4 , base = newBase)
169+ D4Array (newData, newOffset , newShape, dim = D4 , base = newBase)
166170 }
167171 }
168172
@@ -175,12 +179,13 @@ public class NDArray<T, D : Dimension> constructor(
175179
176180 // TODO(get rid of copying)
177181 val newData = if (consistent) this .data else this .deepCopy().data
178- val newBase = if (consistent) base ? : this else null
182+ val newBase = if (consistent) this .base ? : this else null
183+ val newOffset = if (consistent) this .offset else 0
179184
180185 return if (this .shape.contentEquals(newShape)) {
181186 this as NDArray <T , DN >
182187 } else {
183- NDArray (newData, this .offset , newShape, dim = DN (newShape.size), base = newBase)
188+ NDArray (newData, newOffset , newShape, dim = DN (newShape.size), base = newBase)
184189 }
185190 }
186191
@@ -223,9 +228,10 @@ public class NDArray<T, D : Dimension> constructor(
223228 }
224229 // TODO(get rid of copying)
225230 val newData = if (consistent) this .data else this .deepCopy().data
226- val newBase = if (consistent) base ? : this else null
231+ val newBase = if (consistent) this .base ? : this else null
232+ val newOffset = if (consistent) this .offset else 0
227233
228- return NDArray (newData, this .offset , newShape.toIntArray(), dim = DN (newShape.size), base = newBase)
234+ return NDArray (newData, newOffset , newShape.toIntArray(), dim = DN (newShape.size), base = newBase)
229235 }
230236
231237 override infix fun cat (other : MultiArray <T , D >): NDArray <T , D > =
0 commit comments