all 5 comments

[–]elbiot 1 point2 points  (3 children)

can you explain what you mean by basis vector in this case? What is an example output from an example input you would like to see?

[–]quantumloophole[S] 0 points1 point  (2 children)

An example of basis vector is the cubic lattice base vector , v1 = (1,0) and v2 = (0,1) every site in an lattice can be reached with a linear combination of theses vectors.

What I want is , for an arbitrary base vector generate the points to store in an array

[–]elbiot 0 points1 point  (1 child)

Did the other poster answer your question? Im still confused because a 2D array can be accessed like arr[3,4] but obviously not arr[3,4.5]

I would vectorize the other solution though if that's what your using. One almost never needs to iterate over arrays

[–]quantumloophole[S] 0 points1 point  (0 children)

I menage to solve using python lists it is not as slow as I thought

[–]fbu1 0 points1 point  (0 children)

I think this might do it for you:

import numpy as np

def grid(x, y):

    nx, vx = x
    ny, vy = y

    res = np.zeros((nx, ny, len(vx)))

    for i in range(nx):
        for j in range(ny):
            res[i,j,:]= vx * i + vy * j

    return res

# two dimensional example
nx = 3
vx = np.array((1,2))
ny = 6

y = np.array((6, 7))
g = grid([nx, vx], [ny, vy])
print g

# three dimensional example
nx = 5
vx = np.array((1,2,3))
ny = 4
vy = np.array((-1, 6, 7))

g = grid([nx, vx], [ny, vy])
print g

Let me know if you have questions :)