[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reshape implementation ?
From: |
CdeMills |
Subject: |
reshape implementation ? |
Date: |
Wed, 24 Nov 2010 03:01:45 -0800 (PST) |
Hello,
the next problem I'm facing is about reshape. Context:
x=dataframe(randn(3, 3))
Dataframe with 3 rows and 3 columns
_ X1 X2 X3
Nr double double double
1 -0.106705 -0.77947 0.68085
2 0.048692 -0.76935 -0.90692
3 -1.675128 0.84691 1.16656
%#Using matrix conversion:
repmat(mean(x(:,:)), [3 1])
ans =
-0.57771 -0.23397 0.31350
-0.57771 -0.23397 0.31350
-0.57771 -0.23397 0.31350
repmat(mean(x), [3 1])
=> error. It goes around line 72 of reshape.m
m = rows (a); n = columns (a);
p = idx(1); q = idx(2);
x = reshape (a, m, 1, n, 1); => !
reshape: can't reshape 1x1 array to 1x1x3 array
I looked into octave sources; the message is emitted in liboctave/Array.cc,
from the code
template <class T>
Array<T>::Array (const Array<T>& a, octave_idx_type nr, octave_idx_type nc)
: rep (a.rep), dimensions (nr, nc),
slice_data (a.slice_data), slice_len (a.slice_len)
{
if (dimensions.safe_numel () != a.numel ())
{
std::string dimensions_str = a.dimensions.str ();
std::string new_dims_str = dimensions.str ();
(*current_liboctave_error_handler)
("reshape: can't reshape %s array to %s array",
dimensions_str.c_str (), new_dims_str.c_str ());
}
...
How does it come that the argument is a dataframe of size 1x3, yet it is
identified as 1x1 array ? There are overloaded rows, colums, numel and size
function for dataframe.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/reshape-implementation-tp3057070p3057070.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
- reshape implementation ?,
CdeMills <=