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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Reading Data from matrix Pointer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Erik5000

2 Posts

Posted - 03/25/2015 :  09:55:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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?

Castiel

343 Posts

Posted - 03/25/2015 :  12:01:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Why pointer? Why not reference?

妾+   午旦  妹罕妾  妾伊    用仇  妾/     岫ㄞ
 妾京用 仍巨  件 侈   件戶' 甘岫平   /欠  白岫妹
   併             艮          岫  奈 白   岫
                              岫
Go to Top of Page

Erik5000

2 Posts

Posted - 03/26/2015 :  03:43:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!


Edited by - Erik5000 on 03/26/2015 03:44:58 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000