# [SciPy-user] returning floats from a function

Gael Varoquaux gael.varoquaux@normalesup....
Sat Sep 8 06:18:21 CDT 2007

```You probably have an old version of scipy, where "zeros" returns by
default an array of lfoats. You force it to return float by using it like
this:

zeros((3,2), dtype="f")

HTH,

Gaël

On Sat, Sep 08, 2007 at 11:15:42AM +0000, Perez Kawumi wrote:
>    def whitney(elem_num,x,y):

>        global ELEMENTS, NODE_COORD

>        whitney_functions = []
>        whitney_functions = zeros((3,2))

>        perez  = simplex2D(elem_num,x,y)
>        trinodes = ELEMENTS[[elem_num],:]-1

>        x1 = NODE_COORD[trinodes[0,0],0]
>        y1 = NODE_COORD[trinodes[0,0],1]
>        x2 = NODE_COORD[trinodes[0,1],0]
>        y2 = NODE_COORD[trinodes[0,1],1]
>        x3 = NODE_COORD[trinodes[0,2],0]
>        y3 = NODE_COORD[trinodes[0,2],1]
>        #area = 0.5*abs(det([1 x1 y1; 1 x2 y2; 1 x3 y3]));
>        temp = linalg.inv(([x1,x2,x3],[y1,y2,y3],[1,1,1]))
>        b = temp[:,[0]]
>        c = temp[:,[1]]
>          nabla_lambda  = temp[:,0:2]
>        whitney_functions[[0],:] = perez[0]*nabla_lambda[[1],:] -
>    perez[1]*nabla_lambda[[0],:]
>        whitney_functions[[1],:] = perez[0]*nabla_lambda[[2],:] -
>    perez[2]*nabla_lambda[[0],:]
>        whitney_functions[[2],:] = perez[1]*nabla_lambda[[2],:] -
>    perez[2]*nabla_lambda[[1],:]
>        return whitney_functions

```