Code Monkey home page Code Monkey logo

Comments (7)

Zeex avatar Zeex commented on August 29, 2024

Just to clarity, what is arr[2] in your second example supposed to be? Should be it be 0, 4, 8, ... or 0, 2, 4, ... (i.e. same as arr[1])? In the current implementation it would be the latter.

Edit:

The second option probably doesn't make much sense but just to be sure....

from compiler.

Y-Less avatar Y-Less commented on August 29, 2024

I would think the first one. If you want the second do:

new arr[10][20] = {{0, 1, 2, ...}, {0, 2, 4, ...}, {0, 2, 4, ...}, ...};

As with one dimension {0, 1, 1} to fill with almost all 1s using just the last two specified values.

from compiler.

Zeex avatar Zeex commented on August 29, 2024

Forgive me for the dumb question, but I'm still kind of trying to figure out how to calculate arr[2] via arr[0] and arr[1], so far I came up with this:

d = diff_2 - diff_1
arr[2] = { arr[1][0] + d, arr[1][1] + d, ...}

where diff_1 and diff_2 are the differences between the elements of arr[0] and arr[1] respectively. And the question is:

Does this look like the correct formula? I'm asking because this would yield arr[2] as 0, 3, 6 instead of 0, 4, 8 like I wrote before.

Edit:

If instead we do

d = diff_2 / diff_1
arr[2] = { arr[1][0] * d, arr[1][1] * d, ...}

I believe this would give 0, 4, 8 as intended. Still not sure what to do here: for the 1d case we subtracted/added things, but here we are dividing/multiplying (kind of confusing).

from compiler.

Y-Less avatar Y-Less commented on August 29, 2024

I would expect {0, 3, 6}, since the increase is linear.

from compiler.

Y-Less avatar Y-Less commented on August 29, 2024

Actually, I would do it:

arr[0][2] = arr[0][1] + diff(arr[0][0], arr[0][1]); // As in 1-d.
arr[2][0] = arr[1][0] + diff(arr[0][0], arr[1][0]); // Same in the other dimension
arr[2][1] = arr[1][1] + diff(arr[0][1], arr[1][1]);

Thus:

arr[2][2] = arr[2][1] + diff(arr[2][0], arr[2][1]);

Which gives:

{{0, 1, 2, 3, 4,...}, {0, 2, 4, 6, 8, ...},{0, 3, 6, 9,12, ...}}

from compiler.

Zeex avatar Zeex commented on August 29, 2024

Seems working now, if you need an executable for testing you can download it here:
https://ci.appveyor.com/project/Zeex/pawn/branch/master/artifacts

from compiler.

Y-Less avatar Y-Less commented on August 29, 2024

Awesome, thanks.

from compiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.