Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#72 integer valued linspace

Next_Release
closed
itpp (51)
5
2013-05-24
2010-06-03
David Hammarwall
No

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);

Discussion

  • linspace_i patch file

     
    Attachments
  • 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 ?

     
  • 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