Skip to content

[BUG] sum two array result is not correct #3660

Description

@EMinsight

Description

  • Did you build ArrayFire yourself or did you use the official installers
    Myself
  • Which backend is experiencing this issue? (CPU, CUDA, OpenCL)
    CPU
  • Do you have a workaround?
    No
  • Can the bug be reproduced reliably on your system?
    Yes

Reproducible Code and/or Steps

  int n = 5;
  int half = (n - 1) / 2;
  double delta = 1.0 / half;

  af::array coord = delta * (af::range(n) - half);

  af::array coordX = af::tile(coord.T(), n, 1);
  af::array coordY = af::tile(coord, 1, n);

  af::array X2 = coordX * coordX;
  af::array Y2 = coordY * coordY;
  af::array X2Y2 = X2 + Y2;

  af::print("X2", X2);
  af::print("Y2", Y2);
  af::print("X2Y2", X2Y2);

Output:
X2
[5 5 1 1]
1.0000 0.2500 0.0000 0.2500 1.0000
1.0000 0.2500 0.0000 0.2500 1.0000
1.0000 0.2500 0.0000 0.2500 1.0000
1.0000 0.2500 0.0000 0.2500 1.0000
1.0000 0.2500 0.0000 0.2500 1.0000

Y2
[5 5 1 1]
1.0000 1.0000 1.0000 1.0000 1.0000
0.2500 0.2500 0.2500 0.2500 0.2500
0.0000 0.0000 0.0000 0.0000 0.0000
0.2500 0.2500 0.2500 0.2500 0.2500
1.0000 1.0000 1.0000 1.0000 1.0000

X2Y2
[5 5 1 1]
2.0000 0.5000 0.0000 0.5000 2.0000
2.0000 0.5000 0.0000 0.5000 2.0000
2.0000 0.5000 0.0000 0.5000 2.0000
2.0000 0.5000 0.0000 0.5000 2.0000
2.0000 0.5000 0.0000 0.5000 2.0000

System Information

Please provide the following information:

  1. ArrayFire version
    3.9 on Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions