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

Cannot writeln entire object when mixing zip/map #467

Open
jmh530 opened this issue Sep 5, 2023 · 0 comments
Open

Cannot writeln entire object when mixing zip/map #467

jmh530 opened this issue Sep 5, 2023 · 0 comments

Comments

@jmh530
Copy link
Contributor

jmh530 commented Sep 5, 2023

The code below calls byDim on a matrix and then zips it with a vector. I then call map on the combined group (in this case, I reduced it to remove what I was actually doing with it, the code originally was subtracting values of mu from each column).

If I try to print Z[0] or Z[1], I don't have any problems, but if I try to print Z itself, then I get a long error message that starts with a complaint that generating an inout copy constructor failed. I don't have the same problem with Y, suggesting this might be the result of the interaction with zip and map together.

/+dub.sdl:
dependency "mir-algorithm" version="*"
+/
import mir.ndslice.allocation: mininitRcslice;
import mir.ndslice.topology: byDim, map, zip;
import std.stdio: writeln;

void main()
{
    static immutable a = [0.07, 0.125];
    static immutable b = [[-0.1667, -0.1365],
                          [-0.0446,  0.1997],
                          [ 0.0764,  0.3813],
                          [ 0.3230,  0.2999],
                          [-0.0507, -0.2872],
                          [ 0.0130,  0.0975],
                          [ 0.0227,  0.0560],
                          [ 0.0595,  0.1658],
                          [ 0.0374,  0.1834],
                          [ 0.1034,  0.2740]];

    auto mu = mininitRcslice!double(2);
    auto X = mininitRcslice!double(10, 2);
    mu[] = a;
    X[] = b;
    auto Y = X.byDim!1.zip(mu);
    auto Z = Y.map!((a, b) => a);

    writeln(Z[0]); //works
    writeln(Z[1]); //works
    writeln(Z); //fails with long error message
}
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

1 participant