Cube krasch
Closed this issue · 19 comments
Följande:
%This function impute the data using spline again. It will times the number
%of available data with the factor uf
function [oneFreqDatHF] = upSampling(oneFreqDat,uf)
%uf: upsampling factor
if(uf>=2)
uf = floor(uf);
[D,time,temp] = size(oneFreqDat);
oneFreqDatHF = zeros(D,uf*time-uf+1,temp);
%store the new time axis:
for ii = 1:D
oneFreqDatHF(ii,:,1) = oneFreqDat(1,1,1):1/uf:oneFreqDat(1,time,1);
oneFreqDatHF(ii,:,2) = spline(oneFreqDat(ii,:,1),oneFreqDat(ii,:,2),oneFreqDatHF(ii,:,1));
end
else
oneFreqDatHF = oneFreqDat;
end
end
ger:
Traceback (most recent call last):
File ".\mconvert.py", line 53, in <module>
tree = matlab2cpp.main(path, opt.suggestion, disp=opt.display)
File "C:\Python27\lib\site-packages\matlab2cpp\__init__.py", line 148, in main
tree.configure(suggestion=suggestion, disp=disp)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 289, in configure
node.generate(False, None)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 168, in generate
value = value(node)
File "C:\Python27\lib\site-packages\matlab2cpp\targets\reserved.py", line 170, in Assigns_size
rows, cols, slices = map(str, node[0])
ValueError: need more than 0 values to unpack
Fikset.
Jag får fortfarande krascher på samma fil. size för kuber verkar inte fungera, ger följande fel:
Traceback (most recent call last):
File ".\mconvert.py", line 53, in <module>
tree = matlab2cpp.main(path, opt.suggestion, disp=opt.display)
File "C:\Python27\lib\site-packages\matlab2cpp\__init__.py", line 148, in main
tree.configure(suggestion=suggestion, disp=disp)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 289, in configure
node.generate(False, None)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 168, in generate
value = value(node)
File "C:\Python27\lib\site-packages\matlab2cpp\targets\reserved.py", line 149, in Get_size
node.error(
AttributeError: 'Get' object has no attribute 'error'
Raderna:
oneFreqDatHF(ii,:,1) = oneFreqDat(1,1,1):1/uf:oneFreqDat(1,time,1);
oneFreqDatHF(ii,:,2) = spline(oneFreqDat(ii,:,1),oneFreqDat(ii,:,2),oneFreqDatHF(ii,:,1));
ger följande fel:
File ".\mconvert.py", line 53, in <module>
tree = matlab2cpp.main(path, opt.suggestion, disp=opt.display)
File "C:\Python27\lib\site-packages\matlab2cpp\__init__.py", line 148, in main
tree.configure(suggestion=suggestion, disp=disp)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 334, in configure
node.generate(False, None)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 168, in generate
value = value(node)
File "C:\Python27\lib\site-packages\matlab2cpp\targets\cube_common.py", line 47, in Get
node = node.resize()
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 678, in resize
assert self.cls == "Var"
AssertionError
Ah. med types lagt inn blir den problematisk, ja.
Fikset nå.
Jag får fortfarande samma fel för "size".
oneFreqDatHF(ii,:,1) = oneFreqDat(1,1,1):1/uf:oneFreqDat(1,time,1);
oneFreqDatHF(ii,:,2) = spline(oneFreqDat(ii,:,1),oneFreqDat(ii,:,2),oneFreqDatHF(ii,:,1));
oneFreqDatHF(ii, span::all, 1) = ispan(arma::resize(oneFreqDat, oneFreqDat.n_rows, oneFreqDat.n_cols*oneFreqDat.n_slices, 1), 1/uf, oneFreqDat(1, time, 1)) ;
oneFreqDatHF(ii, span::all, 2) = spline(oneFreqDat(ii, span::all, 1), oneFreqDat(ii, span::all, 2), oneFreqDatHF(ii, span::all, 1)) ;
Ett par problem:
Jag har inte headern som innehåller "ispan".
Det är lite konstigt att oneFreqDat(1,1,1) blir till arma::resize(oneFreqDat, oneFreqDat.n_rows, oneFreqDat.n_cols*oneFreqDat.n_slices, 1)
oneFreqDat(1,time,1) har inte fått -1 på index
Man måste uppenbarligen skriva span överallt e.g. oneFreqDat(span(ii), span::all, span(1))
Jupp, her var det noe rart.
Først, problemet med cube indices var ikke løst.
Jeg har tror det er fanget nå. Jeg har ihvertfall:
a(ii,:,1) = a(1,:,ii)
Oversetter til:
a(span(ii-1), span::all, span(0)) = a(span(0), span::all, span(ii-1)) ;
oneFreqDat(1,time,1)
vil ikke bli oversettet i det hele tatt så lenge time er uspesifisert. Evt. løst.
arma::resize skal kun brukes når man har 2 argumenter.
Eskempel:
>> a(1) = [1,2;3,4];
>> a(2) = [5,6;7,8];
>> a(:,:)
ans =
1 3 5 7
2 4 6 8
Fungerer bra på Get, men ikke på Set. Forslag til alternativ løsning tas imot med takk.
ispan
er min "midlertidige" løsning for span
med step.
Jeg kan skrive metoden til filen, men Bjørn hadde lyst til å ha det i separat fil. Jeg har derfor latt det ligge.
Span er oppdatert til kun å bruke span
, med 2 og 3 args hhv. for om step er includert.
>> a(1) = [1,2;3,4];
>> a(2) = [5,6;7,8];
>> a(:,:)
ans =
1 3 5 7
2 4 6 8
fungerar inte för mig.
>> a(1) = [1,2;3,4]
In an assignment A(I) = B, the number of elements in B and I must be the same.
Copy pasta
Inkluder en linje først:
a = ones(2,2,2)
On Tue, May 12, 2015 at 2:36 PM, aronandersson notifications@github.com
wrote:
a(1) = [1,2;3,4];
a(2) = [5,6;7,8];
a(:,:)
ans =
1 3 5 7
2 4 6 8fungerar inte för mig.
a(1) = [1,2;3,4]
In an assignment A(I) = B, the number of elements in B and I must be the same.Reply to this email directly or view it on GitHub
#45 (comment).
Det fungerar ändå inte
>> a = ones(2,2,2);
>> a(1) = [1,2;3,4]
In an assignment A(:) = B, the number of elements in A and B must be the same.
>> a(1)
ans =
1
Urk, svada-kode fungerer ikke.
Heller ikke så viktig, siden det er "bruk av to indexer på cube" som er
kjernen
Men okay, her er kode jeg har testet:
a = ones(2,2,2);
a(:) = 1:8;
a(:,:)
On Tue, May 12, 2015 at 2:55 PM, aronandersson notifications@github.com
wrote:
Det fungerar ändå inte
a = ones(2,2,2);
a(1) = [1,2;3,4]
In an assignment A(:) = B, the number of elements in A and B must be the same.a(1)
ans =
1
Reply to this email directly or view it on GitHub
#45 (comment).
Ok, då förstår jag. Jag har aldrig sett att detta användas i praktiken, men som jag tolkar det så är a(n:m,k:l) samma sak som
aux = reshape(a,size(a,1),size(a,2)*size(a,3),1)
aux(n:m,k:l)
i Armadillo kan man skriva:
mat aux(a.memptr(),a.n_rows,a.n_cols * a.n_slices, false);
//...
I och med "false" så görs ingen djup kopia, så man kan också göra set.
Jag har fortsatt problem med size
cfg found!
loading cfg...
loading scope...
{'upSampling': {'oneFreqDat': 'cube', 'D': 'int', 'temp': 'int', 'oneFreqDatHF': 'cube', 'time': 'int', 'uf': 'double'}}
configuring 92 nodes
Traceback (most recent call last):
File ".\mconvert.py", line 53, in <module>
tree = matlab2cpp.main(path, opt.suggestion, disp=opt.display)
File "C:\Python27\lib\site-packages\matlab2cpp\__init__.py", line 92, in main
tree.configure(suggestion=suggestion, disp=disp)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 289, in configure
node.generate(False, None)
File "C:\Python27\lib\site-packages\matlab2cpp\node.py", line 168, in generate
value = value(node)
File "C:\Python27\lib\site-packages\matlab2cpp\targets\reserved.py", line 149, in Get_size
node.error(
AttributeError: 'Get' object has no attribute 'error'
a = rand(2,2,2)
b = a(:,:)
oversettes nå til:
cube a ;
mat b ;
a = arma::randu<cube>(2, 2, 2) ;
mat _a(a.memptr(), a.n_rows, a.n_cols*a.n_slices, false) ;
b = _a(span::all, span::all) ;
Var det slik du mente?
size
er forresten fikset.
Ok, size verkar fungera nu, förutom att "n_slice" ska vara "n_slices"
Fixed