Re: [sage-support] Re: Evaluating Symbolic Expressions

2011-11-02 Thread Rajeev Singh
On Wed, Nov 2, 2011 at 12:08 PM, Laurent moky.m...@gmail.com wrote:
 In order to anticipate the next question, if you are wotking in a script
 instead of
 the terminal.

 The code

        f(x,y)=x*y
        print f(5,4)

 raises
 SyntaxError: can't assign to function call


 The code
        x,y=var('x,y')
        f=x*y
        print f(4,3)

 raises
 DeprecationWarning: Substitution using function-call syntax and unnamed
 arguments is deprecated and will be removed from a future release of Sage;
 you can use named arguments instead, like EXPR(x=..., y=...)

 I know two correct ways to do that :

        x,y=var('x,y')
        f=x*y
        print f(x=4,y=3)

 or

        x,y=var('x,y')
        f=symbolic_expression(x*y).function(x,y)
        print f(x,y)

 Remark that

        f=symbolic_expression(x*cos(y)).function(x,y)
        print f(0,1)    # 0
        g=symbolic_expression(x*cos(y)).function(y,x)
        print g(0,1)    # 1!!

 Hope it helps in any way

 Laurent



 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org



Hi,

I think its a issue of parsing. If your file is called hello.py it
gives the errors you mentioned. However if you call your file
hello.sage it works. If you call your file hello.sage and run

sage hello.sage

it generates a hello.py which I append below -

# This file was *autogenerated* from the file temp.sage.
from sage.all_cmdline import *   # import sage library
_sage_const_5 = Integer(5); _sage_const_4 = Integer(4)
var('x,y')
__tmp__=var(x,y); f = symbolic_expression(x*y).function(x,y)
print f(_sage_const_5 ,_sage_const_4 )

I think you can now figure out how it is working. Hope it helps.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] gsl in sage outside of notebook

2011-09-17 Thread Rajeev Singh
On Thu, Sep 15, 2011 at 3:24 PM, Rajeev Singh rajs2...@gmail.com wrote:
 On Thu, Sep 15, 2011 at 12:07 PM, Robert Bradshaw
 rober...@math.washington.edu wrote:
 On Wed, Sep 14, 2011 at 2:31 AM, Rajeev Singh rajs2...@gmail.com wrote:
 Hi,

 The following examples compiles from the notebook

 %cython
 cimport sage.gsl.ode
 import sage.gsl.ode
 include 'gsl.pxi'

 cdef class van_der_pol(sage.gsl.ode.ode_system):
    cdef double beta
    def __cinit__(self, double beta=1.0):
        self.beta = beta
    cdef int c_f(self,double t, double *y,double *dydt):
        dydt[0]=y[1]
        dydt[1]=-y[0]-self.beta*y[1]*(y[0]*y[0]-1)
        return GSL_SUCCESS
    cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt):
        dfdy[0]=0
        dfdy[1]=1.0
        dfdy[2]=-2.0*10*y[0]*y[1]-1.0
        dfdy[3]=-10*(y[0]*y[0]-1.0)
        dfdt[0]=0
        dfdt[1]=0
        return GSL_SUCCESS

 However if I put it in a file vander.pyx (say) and use the following 
 setup.py -

 from distutils.core import setup
 from distutils.extension import Extension
 from Cython.Distutils import build_ext

 ext = Extension(vander, [vander.pyx],
    include_dirs = ['/home/rajeev/bin/sage/devel/sage-main/sage/gsl/'])

 setup(ext_modules=[ext],
      cmdclass = {'build_ext': build_ext})


 I get the following error -

 cdef class van_der_pol(sage.gsl.ode.ode_system):
    ^
 

 vander.pyx:10:5: 'ode_system' is not declared


 I guess the problem is with the setup.py. Can someone tell me how to do 
 this?

 IIRC, the notebook %cython creates a setup.py--you could just look at
 that. Chances are your Extension object is missing include dirs and
 libraries.

  -Robert

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


 Hi,

 The present script takes a pyx file as input and outputs a c, o and so
 file in the same directory. The so can now be imported in a sage
 program. I have already checked it and its seems to be working fine. I
 did look at the commands generated by setup.py file to write this
 script.

 Rajeev


Hi,

There is a better (safer I guess) way of doing the task using
something called cython_create_local_so. The following command will do
the job -

sage -c from sage.all import cython_create_local_so;
cython_create_local_so('_laplace.pyx')

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] How to write Sage code to cython code

2011-09-17 Thread Rajeev Singh
On Sat, Sep 17, 2011 at 5:46 PM, Santanu Sarkar
sarkar.santanu@gmail.com wrote:
 Hi all,

 I want to use cython.

 The following code does not work
 %cython
 cdef P
 P = next_prime(ZZ.random_element(2^(100-1),2^100))


 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


Try this -

%cython
from sage.all import *
cdef P
P = next_prime(ZZ.random_element(2^(100-1),2^100))
print P

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] gsl in sage outside of notebook

2011-09-15 Thread Rajeev Singh
On Thu, Sep 15, 2011 at 12:07 PM, Robert Bradshaw
rober...@math.washington.edu wrote:
 On Wed, Sep 14, 2011 at 2:31 AM, Rajeev Singh rajs2...@gmail.com wrote:
 Hi,

 The following examples compiles from the notebook

 %cython
 cimport sage.gsl.ode
 import sage.gsl.ode
 include 'gsl.pxi'

 cdef class van_der_pol(sage.gsl.ode.ode_system):
    cdef double beta
    def __cinit__(self, double beta=1.0):
        self.beta = beta
    cdef int c_f(self,double t, double *y,double *dydt):
        dydt[0]=y[1]
        dydt[1]=-y[0]-self.beta*y[1]*(y[0]*y[0]-1)
        return GSL_SUCCESS
    cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt):
        dfdy[0]=0
        dfdy[1]=1.0
        dfdy[2]=-2.0*10*y[0]*y[1]-1.0
        dfdy[3]=-10*(y[0]*y[0]-1.0)
        dfdt[0]=0
        dfdt[1]=0
        return GSL_SUCCESS

 However if I put it in a file vander.pyx (say) and use the following 
 setup.py -

 from distutils.core import setup
 from distutils.extension import Extension
 from Cython.Distutils import build_ext

 ext = Extension(vander, [vander.pyx],
    include_dirs = ['/home/rajeev/bin/sage/devel/sage-main/sage/gsl/'])

 setup(ext_modules=[ext],
      cmdclass = {'build_ext': build_ext})


 I get the following error -

 cdef class van_der_pol(sage.gsl.ode.ode_system):
    ^
 

 vander.pyx:10:5: 'ode_system' is not declared


 I guess the problem is with the setup.py. Can someone tell me how to do this?

 IIRC, the notebook %cython creates a setup.py--you could just look at
 that. Chances are your Extension object is missing include dirs and
 libraries.

  -Robert

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


Hi,

The present script takes a pyx file as input and outputs a c, o and so
file in the same directory. The so can now be imported in a sage
program. I have already checked it and its seems to be working fine. I
did look at the commands generated by setup.py file to write this
script.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: plot3d with adaptive=True fails

2011-09-15 Thread Rajeev Singh
On Thu, Sep 15, 2011 at 7:10 PM, kcrisman kcris...@gmail.com wrote:


 On Sep 15, 9:08 am, Dan Drake dr...@kaist.edu wrote:
 This is strange:

 x, y =var('x y')
 plot3d(sqrt(x^2+y^2)*sin(1/sqrt(x^2+y^2)), (x,-1/2, 1/2), (y, -1/2, 1/2), 
 adaptive=True)

 fails with ValueError: cannot convert float NaN to integer. Something
 goes wrong when it partitions up the domain, probably when it looks at
 the origin. Is there a way to avoid this? Is this a bug?

 Or rather, very very close to the origin.  I don't have time right
 now, but can you confirm that there is not a depth of recursion
 keyword like there is in 2d plotting?  I would call this a bug.

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


For the time being there is a hack -

x, y, x1, y1 =var('x y x1 y1')

plot3d(lambda x,y: limit(
limit(sqrt(x1^2+y1^2)*sin(1/sqrt(x1^2+y1^2)), x1=x), y1=y), (x,-1/2,
1/2), (y, -1/2, 1/2), adaptive=True) #slow

or

plot3d(lambda x,y: limit(
limit(sqrt(x1^2+y1^2)*sin(1/sqrt(x1^2+y1^2)), x1=x), y1=y) if
x^2+y^21e-4 else sqrt(x^2+y^2)*sin(1/sqrt(x^2+y^2)), (x,-1/2, 1/2),
(y, -1/2, 1/2), adaptive=True)  # dirty but fast

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] gsl in sage outside of notebook

2011-09-14 Thread Rajeev Singh
Hi,

The following examples compiles from the notebook

%cython
cimport sage.gsl.ode
import sage.gsl.ode
include 'gsl.pxi'

cdef class van_der_pol(sage.gsl.ode.ode_system):
cdef double beta
def __cinit__(self, double beta=1.0):
self.beta = beta
cdef int c_f(self,double t, double *y,double *dydt):
dydt[0]=y[1]
dydt[1]=-y[0]-self.beta*y[1]*(y[0]*y[0]-1)
return GSL_SUCCESS
cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt):
dfdy[0]=0
dfdy[1]=1.0
dfdy[2]=-2.0*10*y[0]*y[1]-1.0
dfdy[3]=-10*(y[0]*y[0]-1.0)
dfdt[0]=0
dfdt[1]=0
return GSL_SUCCESS

However if I put it in a file vander.pyx (say) and use the following setup.py -

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext = Extension(vander, [vander.pyx],
include_dirs = ['/home/rajeev/bin/sage/devel/sage-main/sage/gsl/'])

setup(ext_modules=[ext],
  cmdclass = {'build_ext': build_ext})


I get the following error -

cdef class van_der_pol(sage.gsl.ode.ode_system):
^


vander.pyx:10:5: 'ode_system' is not declared


I guess the problem is with the setup.py. Can someone tell me how to do this?

Thanks in advance.
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] noob q: solve in loop doesn't iterate each time

2011-09-07 Thread Rajeev Singh
On Wed, Sep 7, 2011 at 7:31 PM, Chipslinger cbol...@boltoneng.com wrote:
 I've been messing around with using Sage for solving node equations. I
 have the right syntax and structure for creating and symbolically
 solving equations, but am struggling with:
    * Using solve in a loop -- it doesn't evaluate using new
 parameters each time through
    * Printing in decimal format -- I've tried using N(x, digits=4),
 but can't get it to work with the result from solve; I get lots of
 errors

 Here's a simple program I tried last night (using sagenb.org version
 4.7):

 # Schmitt Trigger Threshold Calculation
 var('rtop, rbot, rfd, rout_pullup, vnode, vcc, vin, vthresh')
 rtop = 1
 rbot = 1
 rout_pullup = 1
 rfd = 1e6
 vin = 5
 #vcc = 5
 eq1 = (vin-vnode)/rtop + (vcc-vnode)/(rout_pullup+rfd) == vnode/rbot
 out_states = [0, 5]
 for i in range(2):
    vcc = out_states[i]
    vthresh = solve([eq1], vnode)
    print '%4s: %4s'%(vcc, vthresh)

 Any help or pointers towards relevant docs would be greatly
 appreciated. Thank you in advance.

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org




How about this -


# Schmitt Trigger Threshold Calculation
var('rtop, rbot, rfd, rout_pullup, vnode, vcc, vin, vthresh')
rtop = 1
rbot = 1
rout_pullup = 1
rfd = 1e6
vin = 5
#vcc = 5
eq1 = (vin-vnode)/rtop + (vcc-vnode)/(rout_pullup+rfd) == vnode/rbot
out_states = [0, 5]
vthresh = solve([eq1], vnode)[0].rhs()
for i in range(2):
   vcc = out_states[i]
   print '%4s: %.4f'%(vcc, vthresh.substitute(vcc=vcc).n())

output is -
0: 2.4877
5: 2.5123


I have done very small changes in your code. Hope it helps.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Fwd: Speeding up Python Again

2011-08-23 Thread Rajeev Singh
On Wed, Aug 10, 2011 at 6:48 PM, Rajeev Singh rajs2...@gmail.com wrote:
 Hi,
 I was trying out the codes discussed
 at
http://technicaldiscovery.blogspot.com/2011/07/speeding-up-python-again.html
 Here is a summary of my results -
 Computer: Desktopimsc9aravali   annapurna
NumPy: 7.651419  4.219105  5.576453  4.858640
   Cython: 4.259419  3.477259  3.204909  2.357819
Weave: 4.302778 *  3.298551  2.40
   Looped Fortran: 4.199148  3.414484  3.202963  2.315644
   Vectorized Fortran: 3.118410  2.131966  1.512303  1.460251
 pure fortran update1: 1.205727  1.964857  2.034688  1.336086
 pure fortran update2: 0.600848  0.604649  0.573593  0.721339
 imsc9, aravali and annapurna are HPC machines at my institute
 * for some reason Weave didn't compile on imsc9

 Indeed there is about a factor of 7 to 12 difference between pure fortran
 with update2 (vectorized) and the numpy version.
 I should mention that I changed N to 150 in laplace_for.f90
 Rajeev

Hi,

Continuing the comparison of various ways of implementing solving laplace
equation, following result might interest you -

 Desktop   imsc9  aravali annapurna
Octave (0):  20.7866 *21.6179 *
 Vectorized Fortran (pure) (1):   0.7487  0.6501   0.7507  1.1619
 Vectorized Fortran (f2py) (2):   0.7190  0.6089   0.6243  1.0312
 NumPy (3):   4.1343  2.5844   2.6565  3.7445
Cython (4):   1.7273  1.9927   2.0471  1.3525
 Cython with C (5):   1.7248  1.9665   2.0354  1.3367
 Weave (6):   1.9818 * 2.1326  1.4003
 Looped Fortran (f2py) (7):   1.6996  1.9657   2.0429  1.3354
 Looped Fortran (pure) (8):   1.7189  2.0145   2.0917  1.5086
  C (pure) (9):   1.2820  1.9948   2.0527  1.4259

imsc9, aravali and annapurna are HPC machines at my institute
* for some reason Weave didn't compile on imsc9
* octave isn't installed on imsc9 and annapurna

The difference between numpy and fortran performance seems significant.
However f2py does as well as pure fortran now. The difference from earlier
case is that earlier there was a division inside the loop which I have
replaced by multiplication by reciprocal. This does not affect the result
but makes the execution faster in all cases except pure fortran (I guess
fortran compiler was already doing it).

I would be happy to give all the codes if someone is interested. Should we
update the performance python page at scipy with these codes?

This might be of interest to people doing numerical computation using Sage.
Should we put all these examples in Numerical Sage along with the above
table?

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] fortran example in numerical sage document not working

2011-08-13 Thread Rajeev Singh
Hi,

If I put the following in notebook, I don't get what is expected, i.e. a
function called linearequations -

fortran.libraries = ['lapack', 'blas']

code = '''!f90
Subroutine LinearEquations(A,b,n)
Integer n
Real*8 A(n,n), b(n)
Integer i, j, pivot(n), ok
call DGESV(n, 1, A, n, pivot, b, n, ok)
end
'''

fortran(code)

Although apart from showing some warning it does generate a .so file.
I am using Sage 4.6.2 compiled from source on Debian squeeze. Can someone
suggest how to get it working?

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] ode_solver in cython

2011-08-10 Thread Rajeev Singh
Hi,

I am not able to understand why the following should not work (in notebook)
-

 cell 1 ##
%cython

from sage.all import ode_solver, random

cdef class A:
cdef double mu
def __init__(self, double mu=1.):
self.mu = mu

def func(self, x):
return self.mu*x[0], self.mu*x[1]

def func1():
a = A()
trajectory   = ode_solver()
trajectory.algorithm = rkf45
trajectory.function  = lambda t, y: a.func(y)
trajectory.ode_solve(y_0=[random(), random()], t_span=[0,10],
num_points=100)
u1 = trajectory.interpolate_solution(0)
return u1
## end of cell 1 ###

This compiles without any problem, but when I do -

 cell 2 ##
u1 = func1()
plot(u1, (0,10))
## end of cell 2 ###

I get the following error -
TypeError: arg is not a Python function

If I define func1 outside the cython cell then everything works fine. This
is just a toy problem but captures the behavior I encountered. I hope
someone can explain.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: f2py error within sage

2011-08-03 Thread Rajeev Singh
On Sat, Jul 30, 2011 at 1:42 PM, Rajeev Singh rajs2...@gmail.com wrote:

 Hi,

 I have a script (say a.py) which uses a function written in fortran 90.
 Within the script I give the command to compile using -

 os.system('f2py -c PD_evolve.f90 -m PD_evolve')

 It works fine on my computer if I run the script using -

 python a.py

 However it doesn't work if I use -

 sage -python a.py

 and gives an error while compiling. The last lines of error message are -

 /usr/bin/gfortran -Wall
 /tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/PD_evolvemodule.o
 /tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/fortranobject.o
 /tmp/tmpBTbBKB/PD_evolve.o -L/home/rajeev/bin/sage/local/lib -lpython2.6
 -lgfortran -o ./PD_evolve.so
 /usr/lib/gcc/i486-linux-gnu/4.4.5/libgfortranbegin.a(fmain.o): In function
 `main':
 (.text+0x27): undefined reference to `MAIN__'
 collect2: ld returned 1 exit status
 /usr/lib/gcc/i486-linux-gnu/4.4.5/libgfortranbegin.a(fmain.o): In function
 `main':
 (.text+0x27): undefined reference to `MAIN__'
 collect2: ld returned 1 exit status
 error: Command /usr/bin/gfortran -Wall
 /tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/PD_evolvemodule.o
 /tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/fortranobject.o
 /tmp/tmpBTbBKB/PD_evolve.o -L/home/rajeev/bin/sage/local/lib -lpython2.6
 -lgfortran -o ./PD_evolve.so failed with exit status 1

 I have compiled sage4.6.2 from source on Debian squeeze. I hope it makes
 sense to ask this question here as the trouble is within sage.

 Rajeev



Hi,

Going through the source code of numpy.f2py.compile and fortran in sage, I
managed to get things working. The following code works just fine -

path = os.environ['SAGE_LOCAL']+'/bin/sage-g77_shared'
extra_args = '--f77exec=%s --f90exec=%s' %(path, path)
args = ' -c -m %s %s %s'%('PD_evolve', 'PD_evolve.f90', extra_args)
cmd = '%s -c import numpy.f2py as f2py2e;f2py2e.main() %s'
%(sys.executable,args)
os.system(cmd)

The other thing that worked was InlineFortran from sage.misc.inline_fortran
however it would compile the source every time I run the program, whereas
the above set of instructions create a .so file which can be imported
directly in future runs.

This is just for future reference.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] f2py error within sage

2011-07-30 Thread Rajeev Singh
Hi,

I have a script (say a.py) which uses a function written in fortran 90.
Within the script I give the command to compile using -

os.system('f2py -c PD_evolve.f90 -m PD_evolve')

It works fine on my computer if I run the script using -

python a.py

However it doesn't work if I use -

sage -python a.py

and gives an error while compiling. The last lines of error message are -

/usr/bin/gfortran -Wall
/tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/PD_evolvemodule.o
/tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/fortranobject.o
/tmp/tmpBTbBKB/PD_evolve.o -L/home/rajeev/bin/sage/local/lib -lpython2.6
-lgfortran -o ./PD_evolve.so
/usr/lib/gcc/i486-linux-gnu/4.4.5/libgfortranbegin.a(fmain.o): In function
`main':
(.text+0x27): undefined reference to `MAIN__'
collect2: ld returned 1 exit status
/usr/lib/gcc/i486-linux-gnu/4.4.5/libgfortranbegin.a(fmain.o): In function
`main':
(.text+0x27): undefined reference to `MAIN__'
collect2: ld returned 1 exit status
error: Command /usr/bin/gfortran -Wall
/tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/PD_evolvemodule.o
/tmp/tmpBTbBKB/tmp/tmpBTbBKB/src.linux-i686-2.6/fortranobject.o
/tmp/tmpBTbBKB/PD_evolve.o -L/home/rajeev/bin/sage/local/lib -lpython2.6
-lgfortran -o ./PD_evolve.so failed with exit status 1

I have compiled sage4.6.2 from source on Debian squeeze. I hope it makes
sense to ask this question here as the trouble is within sage.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] dirac delta function

2011-07-11 Thread Rajeev Singh
On Mon, Jul 11, 2011 at 9:43 AM, robin hankin hankin.ro...@gmail.comwrote:

 Hi.

 When I type

 integrate(dirac_delta(x),x,-1,1)


 I expected to get 1, as the documentation clearly implies.

 But instead I get a symbolic answer.

 How do I make sage return 1?




 cheers

 Robin


 --
 Robin Hankin
 Uncertainty Analyst
 hankin.ro...@gmail.com

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


You can use sympy as -

 import sympy
 sympy.integrate(sympy.DiracDelta(x), (x,-1,1))
1

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Log log plots in sage.

2011-06-13 Thread Rajeev Singh
Hi,

One way using pylab is following -

sage: import pylab as plt
sage: x = plt.array([2^ii for ii in range(10)])
sage: y = x^2
sage: plt.loglog(x, y, '.')
[matplotlib.lines.Line2D object at 0x5265d50]
sage: plt.savefig('/home/rajeev/a.png')

Hope it helps.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Import Ellipse module?

2011-05-27 Thread Rajeev Singh
On Thu, May 26, 2011 at 10:26 PM, Mel chemmyg...@gmail.com wrote:

 Do I need to download/load something before I can import the ellipse
 module?

 When I type
from sage.plot.ellipse import Ellipse
 I get ImportError: No module named ellipse

 Thanks!

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


I don't get any error when I execute the above line with sage-4.6.2 on
debian.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: imposing commutation relation

2011-05-26 Thread Rajeev Singh
On Wed, May 25, 2011 at 11:55 AM, Simon King simon.k...@uni-jena.de wrote:

 Hi Rajeev,

 On 25 Mai, 06:14, Rajeev Singh rajs2...@gmail.com wrote:
  sage: R.a,b = FreeAlgebra(QQ, 2)
 
   sage: p = a*(a+2*b)
   sage: list(p)
   [(2, a*b), (1, a^2)]
 
  is there a simple way to reverse this last step?

 I thought that for many parents R holds that R(list(p))==p, but
 apparently I was mistaken.

 However, for example, in the case of polynomials, one has
  sage: P.x,y = QQ[]
  sage: p = P.random_element()
  sage: p
  x*y + 5*y^2 - x + 1
  sage: p.dict()
  {(1, 0): -1, (0, 0): 1, (1, 1): 1, (0, 2): 5}
  sage: P(p.dict()) == p
  True

 But apparently that does not hold for free algebras. Here is a work-
 around using the 'add' function:
   sage: R.a,b = FreeAlgebra(QQ, 2)
  sage: p = a*(a+2*b)
   sage: L = list(p)
  sage: add([c*R(m) for c,m in L], R(0))
  a^2 + 2*a*b

 Cheers,
 Simon

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


Thanks Simon,

One small querry -

sage: R.a,b = FreeAlgebra(QQ, 2)
sage: p = a*(a+2*b)
sage: p
a^2 + 2*a*b
sage: list(p)
[(2, a*b), (1, a^2)]

Why is the order of terms in the list not the same that in string of p (a^2
in string appears before a*b and the opposite happens for the list) ? What
can I do to make them in same order?

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: imposing commutation relation

2011-05-24 Thread Rajeev Singh
Thanks Simon,

i think list of lists and tuples are good enough for me.

sage: R.a,b = FreeAlgebra(QQ, 2)
 sage: p = a*(a+2*b)
 sage: list(p)
 [(2, a*b), (1, a^2)]


is there a simple way to reverse this last step?

just for information - i asked this same question at the sympy mailing list
and i give below parts of the answer which would be important for people
using sage -

The parts below are from the replies of Aaron S. Meurer (asmeu...@gmail.com)
-

 Just a heads up, starting in the next release, symbols('xy') will create
one symbol named xy, not two symbols x and y.  To get around this, you
should do symbols('x y') or symbols('x, y') (this works in the older release
too, so you can start to change your code now).

 In [9]: x, y = symbols('x y', commutative=False)

 In [10]: a = expand((x + y)**3)

 In [11]: a
 Out[11]:
22  3  22  3
 x⋅y⋅x + x⋅y  + x ⋅y + x  + y⋅x⋅y + y⋅x  + y ⋅x + y

 In [12]: a.subs(x*y, y*x + 1)
 Out[12]:
3  2  2  3

 x⋅(1 + y⋅x) + x  + y⋅x  + y⋅(1 + y⋅x) + y ⋅x + y  + (1 + y⋅x)⋅x + (1 +
y⋅x)⋅y

 Actually, it looks like if you are using SymPy 0.6.7, there is a bug that
makes this return a wrong result:

For people using sympy in sage, this last point seems important. I actually
checked and we use SymPy 0.6.4

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: imposing commutation relation

2011-05-23 Thread Rajeev Singh
Hi,

I think my other question got buried in the first one, so here it is again.
If I have -

sage: R.a,b = FreeAlgebra(QQ, 2)
sage: a*(a+b)
a^2 + a*b

Is there a simple way to get a*a instead of a^2 ?

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] imposing commutation relation

2011-05-22 Thread Rajeev
Hi,

I wish to simplify some calculation that appear in quantum mechanics. To 
begin we use non-commutative variables as -

sage: R.a,b = FreeAlgebra(QQ, 2)
sage: (a+b)^3 + a*(a+b)
a^2 + a*b + a^3 + a^2*b + a*b*a + a*b^2 + b*a^2 + b*a*b + b^2*a + b^3

I want to impose the commutation relation [a,b]=1 and bring the expression 
to normal form (i.e. in all terms b appears before a, e.g. a*b gets replaced 
by b*a + 1). Is it possible to do this? If not then can I get the expression 
such that a*b^2 appears as a*b*b? If the later can be done then I can use 
some string manipulation hack and get my job done.

Thanks in advance.

Regards,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: using existing functions with vectors / lists / arrays

2011-05-22 Thread Rajeev Singh
On Sun, May 22, 2011 at 4:45 PM, Berkin Malkoc malk...@gmail.com wrote:




  I have something like:
  y = x^2
 
  I can evaluate it at one point:
  y(2) # 4
 
  I'd like to evaluate it at a group of points:
  y( x ) # 2, 4, 9, 16, ...
 
  Can this just work like in IDL or MATLAB? How would one define x?
  What is the quickest syntax if it can't just be a variable? Perhaps:


 For purely numerical work a la Matlab, you may want to use numpy arrays
 (you will be using Python and not any Sage functionality):

 sage: import numpy
 sage: x = numpy.array([1, 2, 3, 4])
 sage: def y(x):
 : return x*x
 :
 sage: y(x)
 array([ 1,  4,  9, 16])

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


if the function of the single variable is somewhat more complicated then one
can use vectorize from numpy -

sage: import numpy as np
sage: x = np.array([1,2,3,4])
sage: x
array([1, 2, 3, 4])
sage: def y(x):
: if x  3:
: return 2*x
: else:
: return x*x
:
sage: y_vec = np.vectorize(y)

this fails -
sage: y(x)
---
ValueErrorTraceback (most recent call last)



while this works -
sage: y_vec(x)
array([ 2,  4,  9, 16])

hope it helps.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] regarding arrayobject.h

2010-08-09 Thread Rajeev
Hi,

I was trying to work out the first example given in

http://wiki.cython.org/WrappingNumpy

in sage notebook, but got an error saying

arrayobject.h not found. How do I get this example working?


Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] sage much slower than ipython

2010-08-05 Thread Rajeev
Hi,

I was very surprised to find that sage is much slower than ipython for
doing the same numerical task (monte carlo simulation using numpy
arrays). Following is summary of the time taken -

In [1]: from layered_ising_mc import layered_ising_mc

In [2]: a = layered_ising_mc(n=16, J_p=20, h=19.94, beta=0.5)

In [3]: a.set_initial_condition()

In [4]: time data = a.monte_carlo(1000); a.check_consistency()
CPU times: user 16.89 s, sys: 0.03 s, total: 16.93 s
Wall time: 17.43 s


sage: from layered_ising_mc import layered_ising_mc
sage: a = layered_ising_mc(n=16, J_p=20, h=19.94, beta=0.5)
sage: a.set_initial_condition()
sage: time data = a.monte_carlo(1000); a.check_consistency()
CPU times: user 191.94 s, sys: 0.11 s, total: 192.04 s
Wall time: 194.03 s

I was surprised that the difference is a factor of 10. I hope I am not
comparing apples to oranges.

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: sage much slower than ipython

2010-08-05 Thread Rajeev

 Can you try doing

 sage: preparser(False)

sage: preparser(False)
sage: from layered_ising_mc import layered_ising_mc
sage: a = layered_ising_mc(n=16, J_p=20, h=19.94, beta=0.5)
sage: a.set_initial_condition()
sage: time data = a.monte_carlo(1000); a.check_consistency()
CPU times: user 40.59 s, sys: 0.02 s, total: 40.61 s
Wall time: 41.68 s

That seems OK now.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] error using scipy sparse matrix

2010-06-22 Thread Rajeev
Hi,

I think following is a bug -

sage: from scipy import sparse
sage: a = sparse.lil_matrix((10,10))
sage: a[1,2] = 1
---
ValueErrorTraceback (most recent call
last)

/home/rajeev/programs/sitabhra/beads/FN_chain/ipython console in
module()

/home/rajeev/bin/sage/local/lib/python2.6/site-packages/scipy/sparse/
lil.pyc in __setitem__(self, index, x)
320 self._insertat3(row, data, j, xx)
321 else:
-- 322 raise ValueError('invalid index value: %s' %
str((i, j)))
323
324 def _mul_scalar(self, other):

ValueError: invalid index value: (1, 2)

It works in the python shell.

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] unable to run spyx file

2010-06-08 Thread Rajeev
Hi,

I was trying to run a spyx file but got the following error

11:25:23 $ sage prime_pattern1.spyx  input
Traceback (most recent call last):
  File /home/rajeev/bin/sage/local/bin/sage-sagex, line 5, in
module
from sage.misc.interpreter import load_sagex
ImportError: cannot import name load_sagex

How do I take care of this?

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] interact question

2010-05-18 Thread Rajeev Singh
here is the answer to the first thing. use auto_update=False -

sage: @interact
... def _(A=matrix(QQ,3,3,range(9)), v=matrix(QQ,3,1,range(3)),
auto_update=False):
... try:
... x = A\v
... html('$$%s %s = %s$$'%(latex(A), latex(x), latex(v)))
... except:
... html('There is no solution to $$%s x=%s$$'%(latex(A),
latex(v)))

Rajeev


On Tue, May 18, 2010 at 1:50 PM, ma...@mendelu.cz ma...@mendelu.cz wrote:

 Dear support, this code is from interact help:

 sage: @interact
 ... def _(A=matrix(QQ,3,3,range(9)), v=matrix(QQ,3,1,range(3))):
 ... try:
 ... x = A\v
 ... html('$$%s %s = %s$$'%(latex(A), latex(x), latex(v)))
 ... except:
 ... html('There is no solution to $$%s x=%s$$'%(latex(A),
 latex(v)))

 If I want to change five numbers in the matrix A, I get a solution
 whenever I change each field.
 Is it possible to change all my five fields first and the let interact
 to compute the answer? In other words, interact should not do
 anything, unless asked explicitly.

 I was thinking about adding a checkbox and perform the computation
 only if the checkbox is on, but this gives another problem: how to
 uncheck the checkbox from Sage interact after computation is done.

 I am thinking about an interact which allows some comfortable
 manipulations with matrix rows and can be used for row pivoting,
 evaluating inverse functions, solving systems of linear equations and
 evaluating rank and determinants. For example, can be used on
 recitations. If something like this has been done, let me know,
 please. Many thanks

 Robert Marik

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
 sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] problem with multi line program statement in notebook

2010-05-14 Thread Rajeev
Hi,

I am getting the following error in the notebook

1 + \
2

Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_34.py, line 10, in module
exec compile(u'open(___code___.py,w).write(# -*- coding:
utf-8 -*-\\n +
_support_.preparse_worksheet_cell(base64.b64decode(MSArIFwKMg==),globals())
+\\n); execfile(os.path.abspath(___code___.py))
  File , line 1, in module

  File /tmp/tmpts66v1/___code___.py, line 4
exec compile(u'_sage_const_2
   ^
SyntaxError: invalid syntax

I am using version 4.4.1. I couldn't find a discussion about it
recently. Is someone else also getting the same error?

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] some basics of weave

2010-05-12 Thread Rajeev
Hi,
I was trying to learn a bit of weave, but there seems to be some
problem. The code I used is

import scipy.weave as weave
a, b = 10, 5
code = \
'''
int temp;
temp = a;
a = b;
b = temp;
'''
weave.inline(code, ['a', 'b'])
print a, b

When I ran this code in sage notebook, I got the following error

Traceback (most recent call last):print a, b
  File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/
scipy/weave/inline_tools.py, line 321, in inline
results = attempt_function_call(code,local_dict,global_dict)
  File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/
scipy/weave/inline_tools.py, line 389, in attempt_function_call
function_list = function_catalog.get_functions(code,module_dir)
  File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/
scipy/weave/catalog.py, line 612, in get_functions
function_list = self.get_cataloged_functions(code)
  File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/
scipy/weave/catalog.py, line 526, in get_cataloged_functions
if cat is not None and code in cat:
  File /home/rajeev/bin/sage-4.2/local/lib/python/shelve.py, line
110, in __contains__
return key in self.dict
  File /home/rajeev/bin/sage-4.2/local/lib/python2.6/site-packages/
scipy/io/dumbdbm_patched.py, line 73, in __getitem__
pos, siz = self._index[key] # may raise KeyError
KeyError: 0

The same code runs in python, but doesn't do what I want it to do,
i.e. interchange the values of a and b. I think this is due to 'call
by value' but I am not sure. I hope its OK to ask this question here.

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: some basics of weave

2010-05-12 Thread Rajeev
Hi,

 In sage notebook, start the cell with %python in the very first line.

%python doesn't help, getting the same error.

 suggest you to look into cython because that's the weave we use

I am trying to understand the scope of variables while using weave :)
Thanks anyway.
As I said earlier -

 The same code runs in python, but doesn't do what I want it to do,
 i.e. interchange the values of a and b. I think this is due to 'call
 by value' but I am not sure. I hope its OK to ask this question here.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] strange behavior on assigning string with single quotes

2010-05-12 Thread Rajeev
Hi,

I am finding a very strange behavior in notebook. Evaluating

a = 'hello'

gives

Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_12.py, line 4, in module
print _support_.syseval(python, ur\u0027\u0027\u0027a = \u0027hello
\u0027\u0027\u0027\u0027, \u0027/home/rajeev/sage_notebook/
sage_notebook.sagenb/home/admin/32/cells/25\u0027)
  File , line 1
print _support_.syseval(python, ur'''a = 'hello, '/home/rajeev/
sage_notebook/sage_notebook.sagenb/home/admin/32/cells/25')
 
^
SyntaxError: EOL while scanning string literal

There is no problem when I use double quotes. I am using sage 4.2 and
I have selected python from the dropdown menu at the top.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: strange behavior on assigning string with single quotes

2010-05-12 Thread Rajeev
Let me also add that there is no problem if the dropdown menu at the
top is set at sage (the default option).



On May 12, 4:31 pm, Rajeev rajs2...@gmail.com wrote:
 Hi,

 I am finding a very strange behavior in notebook. Evaluating

 a = 'hello'

 gives

 Traceback (most recent call last):
   File stdin, line 1, in module
   File _sage_input_12.py, line 4, in module
     print _support_.syseval(python, ur\u0027\u0027\u0027a = \u0027hello
 \u0027\u0027\u0027\u0027, \u0027/home/rajeev/sage_notebook/
 sage_notebook.sagenb/home/admin/32/cells/25\u0027)
   File , line 1
     print _support_.syseval(python, ur'''a = 'hello, '/home/rajeev/
 sage_notebook/sage_notebook.sagenb/home/admin/32/cells/25')

 ^
 SyntaxError: EOL while scanning string literal

 There is no problem when I use double quotes. I am using sage 4.2 and
 I have selected python from the dropdown menu at the top.

 Rajeev

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/sage-support
 URL:http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] weighted graph plotting

2010-04-27 Thread Rajeev
Hi,

I want to plot weighted graphs such that the link-width or color may
have the information of relative weights. Please point the relevant
document page. I couldn't find one.

Best wishes,
Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: weighted graph plotting

2010-04-27 Thread Rajeev
Thanks Jason,

But the color assigned is random. I wonder if it is possible to assign
it systematically (like image in matplotlib) and possibly with a
colorbar.

Rajeev


On Apr 27, 7:28 pm, Jason Grout jason-s...@creativetrax.com wrote:
 On 04/27/2010 07:32 AM, Rajeev wrote:

  Hi,

  I want to plot weighted graphs such that the link-width or color may
  have the information of relative weights. Please point the relevant
  document page. I couldn't find one.

 Does this work?

 sage: g=DiGraph(random_matrix(ZZ,5))
 sage: g.weighted_adjacency_matrix()
 [  1   1  -1   2  -1]
 [  1   3 -38  -3   4]
 [ -2  -1  -1  -1  -1]
 [  1  -1  -1   1   5]
 [ -1   2  -2  -3  -7]
 sage: plot(g, color_by_label=True)

 Seehttp://www.sagemath.org/doc/reference/sage/graphs/generic_graph.html#...

 Thanks,

 Jason

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/sage-support
 URL:http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: ndsolve??

2010-03-28 Thread Rajeev
Hi,
sage has gsl as one of the included packages, which is very good for
numerical solution of differential equations. have a look at examples
on the wikipage -
http://wiki.sagemath.org/interact/diffeq
'Vector Field with Runga-Kutta-Fehlberg' by Schilly is one of my
favorites. i hope it will help.
Best wishes,
Rajeev


On Mar 26, 11:06 am, dabu pallabb...@gmail.com wrote:
 Hi,
 Many thanks. I will try to have a look.
 best,
 Pallab
 On Mar 25, 1:05 pm, Jason Grout jason-s...@creativetrax.com wrote:

  On 03/25/2010 10:25 AM, dabu wrote:

   Hi,

   I am new in sage. I was wondering about Sage's capability to solve
   odes numerically.

   I was expecting to find something which is like ndsolve of
   Mathematica.
   For example it should not only as for the first order equations, nor
   that one has to supply jacobians manually. It should also tackle
   boundary conditions as equations.

   I wonder any such things exist. Without such a construct. Sage would
   not be useful (read compete with Mathematica :)) to a large part of
   theoretical physics community.

   I would be happy to write such a thing in case it does not exist.

  I've always just used the scipy functions to do this sort of thing,
  though I'm not an expert in the area, so I'm not sure what the scipy
  functionality is missing.  See:

 http://www.sagenb.org/home/pub/258/-basic 
 examplehttp://www.sagenb.org/home/pub/106/-calculating streamlines in 
 Sagehttp://www.sagenb.org/home/pub/879/-epidemic 
 modelinghttp://www.sagenb.org/home/pub/42/-spring-mass systems

  Docs:

 http://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html#ord...

 http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.o...

 http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.o...

  It would be great to have something like this (or wrap the scipy stuff)
  in Sage, so if you want to contribute, go for it!  I would be glad to
  see it.

  Thanks,

  Jason

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: monte carlo integration

2010-02-05 Thread Rajeev
Hi,

There is a cython script for the example given in the gsl document.
The file is examples/gsl/examples/monte.pyx in the sage package.
Looking at this example is quite instructive.

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: monte carlo integration

2010-02-03 Thread Rajeev
Hi,

SAGE wraps GSL which has monte carlo integration routines. You may
look at the source file gsl_monte.pxi and the gsl document at -

http://www.gnu.org/software/gsl/manual/html_node/Monte-Carlo-Integration.html

Rajeev



On Feb 3, 7:23 pm, ggrafendorfer georg.grafendor...@gmail.com wrote:
 Hi all,

 does anybody know if there is a Monte Carlo integration algorithm in
 Sage or any of the packages shipped with Sage?

 thanks, Georg

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: create a subdiagonal matrix quickly

2009-06-21 Thread Rajeev Singh

 I should mention that these methods are all nice for this problem, but
 they also end up copying an awful lot of zeros.  I think it would be way
 more efficient in general to make a zero matrix, then set the right
 diagonal by hand using a for loop.


Don't you think using a sparse matrix would be a better thing to do in such
situations?

Rajeev

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] unable to get SAGE working on my debian lenny machine ...

2009-05-26 Thread Rajeev Singh
Hi,
I have recently started using SAGE on sagenb.org and I am very impressed by
it.
I have downloaded the full system and was following the instruction given,
but it didn't work for me.
Precisely, the following problems come -

1. it is unable to execute the binary file

10:38:07 $ ./sage
--
| Sage Version 3.4.1, Release Date: 2009-04-21   |
| Type notebook() for the GUI, and license() for information.|
--
/home/rajeev/sage/local/bin/sage.bin: /home/rajeev/sage/local/bin/sage.bin:
cannot execute binary file

2. on giving make, the first few lines are-

10:38:11 $ make
cd spkg  ./install all 21 | tee -a ../install.log
/bin/ls: cannot access bzip2-*-install: No such file or directory
/bin/ls: cannot access dir-*-install: No such file or directory
/bin/ls: cannot access prereq-*-install: No such file or directory
...

Though I have been using linux for sometime, I am good enough to understand
what's going on here.

Best,
Rajeev

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: unable to get SAGE working on my debian lenny machine ...

2009-05-26 Thread Rajeev Singh
Thanks a lot William.
This was the problem.


 He downloaded the wrong binary for his computer/OS.  Maybe he
 downloaded a 64-bit binary for a 32-bit operating system or something.


I downloaded the correct binary and its working fine.
Sorry for a question, which should not have been there in first place!

Thanks again,
Rajeev

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---