The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Reading Data from matrix Pointer

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Erik5000 Posted - 03/25/2015 : 09:55:13 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2015G 64bit Sr2
Operating System: Win7 64 Bit
Hi there,

i'm struck with accessing matrix Data with help of a pointer.

e.g.:


int main()
{
    matrix<double> values = {{3,2},{2,3}};
    matrix<double> *test;
    double value;

    test = &values;
	
    value = test[0][1];
    printf("%.f", value);

    return 0
}



...leads to a compiler error (illegal indexed dereference). Accessing methods of the matrixbase or matrix class works with ->, but indexing with [i][j] fails.

I was unable to find a method for accessing data by a given coordinate.

Whats the right way of accessing data in this case?
2   L A T E S T    R E P L I E S    (Newest First)
Erik5000 Posted - 03/26/2015 : 03:43:39 AM
Hey, thank you for your reply

i didn't know about references in origin c (it doesn't work in standard c as far as i know, but maybe i'm wrong there^^)

so:

int main()
{
    matrix<double> values = {{3,2},{2,3}};
    matrix<double> &reference = values;
	
    sub(referenz);
	
    printf("%.f\n", reference[0][1]);

    return 0
}

int sub(matrix<double> &values)
{
    printf("%.f\n", values[0][1]);
    values[0][1] = 45;
    return 0
}


does the trick, thank you!

Castiel Posted - 03/25/2015 : 12:01:27 PM
Why pointer? Why not reference?

©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000