Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/numerical/test.py
4045 views
1
"""
2
Doctests for cvxopt, scipy
3
4
sage: from cvxopt.base import *
5
sage: from cvxopt import umfpack
6
sage: from scipy import optimize
7
sage: from scipy import special
8
sage: from scipy import integrate
9
sage: from scipy.sparse.linalg import dsolve
10
sage: from scipy import interpolate
11
sage: from scipy import sparse
12
sage: from scipy.sparse.linalg.eigen.arpack import arpack
13
14
#Test arpack
15
#This matrix is the finite difference approximation to
16
# the eigenvalue problem
17
#d^2f/dx^2=\lambda f, on [0,\pi], which boundary values 0
18
# The lowest eigenvalue calulated should be close to 1
19
sage: import scipy
20
sage: from scipy.sparse.linalg.interface import aslinearoperator
21
sage: n=scipy.zeros((3,500))
22
sage: n[0,:]=-1
23
sage: n[1,:]=2
24
sage: n[2,:]=-1
25
sage: A=sparse.spdiags(n,[-1,0,1],int(500),int(500))
26
sage: A=aslinearoperator(A)
27
sage: e,v=arpack.eigs(A,k=6,which='SM') # long time (4s on sage.math, 2012)
28
sage: e[0]*float(501/pi)**2 # long time
29
(0.999...+0j)
30
"""
31
32
33