simit-lang / simit

A language for computing on sparse systems
http://simit-lang.org
Other
454 stars 52 forks source link

Scalar FieldRef are not printing #63

Closed VikingScientist closed 8 years ago

VikingScientist commented 8 years ago

FieldRef vector and matrices print nicely to screen, but scalar (float and int) just output empty strings

#include "graph.h"
#include <iostream>

using namespace simit;
using namespace std;

int main(int argc, char **argv) {
    Set verts;
    FieldRef<double,2,2>  A = verts.addField<double,2,2>("A");
    FieldRef<double,3>    x = verts.addField<double,3>(  "x");
    FieldRef<double>      u = verts.addField<double>(    "u");
    FieldRef<int>         i = verts.addField<int>(       "i");

    ElementRef pt;
    pt = verts.add();
    A(pt) = {0,0,0,0};
    x(pt) = {0,0,0};
    u(pt) = 0;
    i(pt) = 0;
    pt = verts.add();
    A(pt) = {1,2,3,4};
    x(pt) = {1,0,0};
    u(pt) = 12.3;
    i(pt) = 1;

    for(auto e : verts) {
        cout << A(e) << endl; // prints matrix
        cout << x(e) << endl; // prints vector
        cout << u(e) << endl; // prints nothing
        cout << i(e) << endl; // prints nothing
        double value = u(e);
        cout << value << endl;// prints correct value
    }

}