Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorize vs. indexing #70

Open
jonathf opened this issue Jul 1, 2015 · 0 comments
Open

Vectorize vs. indexing #70

jonathf opened this issue Jul 1, 2015 · 0 comments
Assignees

Comments

@jonathf
Copy link
Owner

jonathf commented Jul 1, 2015

Case:

>> A = rand(4,4)
A =
0.8147    0.6324    0.9575    0.9572
0.9058    0.0975    0.9649    0.4854
0.1270    0.2785    0.1576    0.8003
0.9134    0.5469    0.9706    0.1419
>> b = [1,2;2,3;3,5] ;
>> A(b)
ans =
0.8147    0.9058
0.9058    0.1270
0.1270    0.6324

Med andre ord, Matlab vectoriserer A, henter ut ved hjelp av singel index, og fyller verdiene etter shape definert av argumentet. Mao:

A([1;2]) == [A(1); A(2)]

Tilsvarende for alle andre shapes.

@aronandersson, forslaget vi dikuterte brukte jeg forslaget:

arma::vectorise(A)(arma::vectorise(b))

Du foreslo:

A(b(0), b(1))

Men hverken løser problemet korrekt.

I min verden burde vi lagen en inline function, eller er det en annen måte å gjøre dette på?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants