#72 integer valued linspace

itpp (51)

A very common operation is to create an integer vector with a uniform spacing between neighboring elements; for example, [1 2 3 4], [-1 2 5 8], etc. Currently this is cumbersome to do in runtime (i.e., when the string notation, "-1:3:8" is unsuitable because the starting or ending value is determined at runtime).

Therefore it would be useful with an integer equivalent to linspace. Attached is a patch file that implements an integer linspace function with the following syntax:
ivec linspace_i(int from, int length, int spacing = 1);


  • Bogdan Cristea

    Bogdan Cristea - 2010-09-05

    Such a function would be useful, but I am thinking to implement a templated function, allowing to use also double/float in order to have a similar behavior to MATLAB. Any thoughts ?

  • David Hammarwall

    Sounds like a really good idea, and the current implementation should be readily converted into a templated version.

  • Bogdan Cristea

    Bogdan Cristea - 2010-12-04

    the name of the function is linspace_fixed_step()

  • Bogdan Cristea

    Bogdan Cristea - 2013-05-23
    • status: open --> accepted
    • assigned_to: Bogdan Cristea
  • Bogdan Cristea

    Bogdan Cristea - 2013-05-24
    • status: accepted --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks