bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 800 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 801 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 802 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 803 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 804 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 805 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 806 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 807 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 808 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 809 |
def d_restrict_source(workd,subjslots,source): """ | def d_restrict_source(workd,subjslots,source): """ | 810 |
def multivar_sscalc(workd): | def multivar_sscalc(workd): | 811 |
def subtr_cellmeans(workd,subjslots): """ | def subtr_cellmeans(workd,subjslots): """ | 812 |
def subtr_cellmeans(workd,subjslots): """ | def subtr_cellmeans(workd,subjslots): """ | 813 |
def subtr_cellmeans(workd,subjslots): """ | def subtr_cellmeans(workd,subjslots): """ | 814 |
def speye(n, m = None, k = 0, dtype = 'd'): """ speye(n, m) returns a (n x m) matrix stored in CSC sparse matrix format, where the k-th diagonal is all ones, and everything else is zeros. """ diags = ones((1, n), dtype = dtype) return spdiags(diags, k, n, m) | def speye(n, m = None, k = 0, dtype = 'd'): """ speye(n, m) returns a (n x m) matrix stored in CSC sparse matrix format, where the k-th diagonal is all ones, and everything else is zeros. """ diags = ones((1, n), dtype = dtype) return spdiags(diags, k, n, m) | 815 |
def fminbound(func, x1, x2, args=(), xtol=1e-5, maxfun=500, full_output=0, disp=1): """Bounded minimization for scalar functions. Description: Finds a local minimizer of the scalar function func in the interval x1 < xopt < x2 using Brent's method. (See brent for auto-bracketing). Inputs: func -- the function to be... | def fminbound(func, x1, x2, args=(), xtol=1e-5, maxfun=500, full_output=0, disp=1): """Bounded minimization for scalar functions. Description: Finds a local minimizer of the scalar function func in the interval x1 < xopt < x2 using Brent's method. (See brent for auto-bracketing). Inputs: func -- the function to be... | 816 |
def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If... | def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If... | 817 |
def golden(func, args=(), brack=None, tol=_epsilon, full_output=0): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is... | def golden(func, args=(), brack=None, tol=_epsilon, full_output=0): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is... | 818 |
def bracket(func, xa=0.0, xb=1.0, args=(), grow_limit=110.0): """Given a function and distinct initial points, search in the downhill direction (as defined by the initital points) and return new points xa, xb, xc that bracket the minimum of the function: f(xa) > f(xb) < f(xc) """ _gold = 1.618034 _verysmall_num = 1e-21... | def bracket(func, xa=0.0, xb=1.0, args=(), grow_limit=110.0): """Given a function and distinct initial points, search in the downhill direction (as defined by the initital points) and return new points xa, xb, xc that bracket the minimum of the function: f(xa) > f(xb) < f(xc) """ _gold = 1.618034 _verysmall_num = 1e-21... | 819 |
def check_exact(self): resdict = {(10,2):45L, (10,5):252L, (1000,20):339482811302457603895512614793686020778700L, (1000,975):47641862536236518640933948075167736642053976275040L, (-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11),0L} for key in resdict.keys(): assert_equal(comb(key[0],key[1],exact=1),resdict[key]) | def check_exact(self): resdict = {(10,2):45L, (10,5):252L, (1000,20):339482811302457603895512614793686020778700L, (1000,975):47641862536236518640933948075167736642053976275040L, (-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11):0L} for key in resdict.keys(): assert_equal(comb(key[0],key[1],exact=1),resdict[key]) | 820 |
def getH(self): return self.transpose().conj() # csc = self.tocsc() # new = csc.transpose() # new.data = conj(new.data) # return new | def getH(self): return self.transpose().conj() # csc = self.tocsc() # new = csc.transpose() # new.data = conj(new.data) # return new | 821 |
def dot(self, other): """ A generic interface for matrix-matrix or matrix-vector multiplication. Returns A.transpose().conj() * other or A.transpose() * other. """ M, K1 = self.shape try: K2, N = other.shape except (AttributeError, TypeError): # Not sparse or dense. Interpret it as a sequence. try: return self.matvec... | def dot(self, other): """ A generic interface for matrix-matrix or matrix-vector multiplication. Returns A.transpose().conj() * other or A.transpose() * other. """ M, K1 = self.shape try: K2, N = other.shape except (AttributeError, TypeError): # Not sparse or dense. Interpret it as a sequence. try: return self.matvec... | 822 |
def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | def save(self, file_name, format = '%d %d %f\n'): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close()... | 823 |
def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open(file_name, 'w') except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close()... | 824 |
def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write('%d %d\n' % self.shape) fd.write('%d\n' % self.size) for ii in xrange(self.size): ir, ic = self.rowcol(ii) data = self.getdata(ii) fd.write(format % (ir, ic, data)) fd.close() | 825 |
def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | 826 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | def __init__(self, arg1, dims=None, nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): M, N = ... | 827 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | 828 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = arg1 if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): M, N = s.... | 829 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | 830 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | 831 |
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other.transpose()).transpose() | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other.transpose()).transpose() | 832 |
def matvec(self, other): if isdense(other): if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'cscmux') y = func(self.data, self.rowind, self.indptr, other, self.shape[0]) return y elif isspmatrix(other): raise NotImplementedError, "use... | def matvec(self, other): if isdense(other): func = getattr(sparsetools, self.ftype+'cscmux') y = func(self.data, self.rowind, self.indptr, other, self.shape[0]) return y elif isspmatrix(other): raise NotImplementedError, "use matmat() for sparse * sparse" else: raise TypeError, "need a dense vector" | 833 |
def rmatvec(self, other, conjugate=True): if isdense(other): if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.rowind, self.indptr, other) return y elif... | def rmatvec(self, other, conjugate=True): if isdense(other): func = getattr(sparsetools, self.ftype+'csrmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.rowind, self.indptr, other) return y elif isspmatrix(other): raise NotImplementedError, "use matmat() for sparse * sparse" else: raise T... | 834 |
def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _trans... | def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _trans... | 835 |
def __getitem__(self, key): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscgetel') M, N = self.shape if not (0<=row<M) or not (0<=col<N): raise KeyError, "index out of bounds" ind, val = func(self.data, self.rowind, self.indptr, row, col) return val #elif isins... | def __getitem__(self, key): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscgetel') M, N = self.shape if not (0<=row<M) or not (0<=col<N): raise IndexError, "index out of bounds" ind, val = func(self.data, self.rowind, self.indptr, row, col) return val #elif isi... | 836 |
def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise IndexError, "index out of bounds" if (col >= N): self.indptr = res... | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise IndexError, "index out of bounds" if (col >= N): self.indptr = res... | 837 |
def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new | def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new | 838 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | def __init__(self, arg1, dims=None, nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape = (ocs... | 839 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | 840 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = arg1 ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape = (ocsc.... | 841 |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | 842 |
def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): # Now we would add this scalar to every element. raise NotImplementedError, 'adding a scalar to a sparse matrix ' \ 'is not yet supported' elif isspmatrix(other): ocs = other.tocsr() if (ocs.shape ... | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): # Now we would add this scalar to every element. raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ 'is not yet supported' elif isspmatrix(other): ocs = other.tocsr() if (ocs.shape != ... | 843 |
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data # allows type conversion new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other... | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data # allows type conversion new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: try: tr = other.transpose() except AttributeError: tr =... | 844 |
def matvec(self, other): if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') y = func(self.data, self.colind, self.indptr, other) return y | def matvec(self, other): if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') y = func(self.data, self.colind, self.indptr, other) return y | 845 |
def rmatvec(self, other, conjugate=True): if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'cscmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.colind, self.indptr, other, self.shape[1]) return y | def rmatvec(self, other, conjugate=True): func = getattr(sparsetools, self.ftype+'cscmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.colind, self.indptr, other, self.shape[1]) return y | 846 |
def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise KeyError, "index out of bounds" if (row >= M): self.indptr = resiz... | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise IndexError, "index out of bounds" if (row >= M): self.indptr = res... | 847 |
def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise KeyError, "index out of bounds" if (row >= M): self.indptr = resiz... | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise KeyError, "index out of bounds" if (row >= M): self.indptr = resiz... | 848 |
# def csc_cmp(x, y): | # def csc_cmp(x, y): | 849 |
def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... | def __init__(self, A=None, dtype='d'): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate... | 850 |
def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... | def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... | 851 |
def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] =... | 852 |
def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] =... | 853 |
def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | 854 |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] ... | 855 |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | def__radd__(self,other):#Firstcheckifargumentisascalarifisscalar(other)or(isdense(other)andrank(other)==0):new=dok_matrix()#Addthisscalartoeveryelement.M,N=self.shapeforiinrange(M):forjinrange(N):aij=self.get((i,j),0)+otherifaij!=0:new[i,j]=aij#new.dtype.char=self.dtype.charelifisinstance(other,dok_matrix):new=dok_matr... | 856 |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] ... | 857 |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | 858 |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | 859 |
def __neg__(self): new = dok_matrix() for key in self.keys(): new[key] = -self[key] return new | def __neg__(self): new = dok_matrix(self.shape, dtype=self.dtype) for key in self: new[key] = -self[key] return new | 860 |
def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(other) | def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(... | 861 |
def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(other) | def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.iteritems(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(other) | 862 |
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix(self.shape, dtype=self.dtype) # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(... | 863 |
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.iteritems(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.trans... | 864 |
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | 865 |
def transpose(self): """ Return the transpose """ newshape = (self.shape[1], self.shape[0]) new = dok_matrix(newshape) for key in self.keys(): new[key[1], key[0]] = self[key] return new | def transpose(self): """ Return the transpose """ m, n = self.shape new = dok_matrix((n, m), dtype=self.dtype) for key, value in self.iteritems(): new[key[1], key[0]] = value return new | 866 |
def conjtransp(self): """ Return the conjugate transpose """ new = dok_matrix() for key in self.keys(): new[key[1], key[0]] = conj(self[key]) return new | def conjtransp(self): """ Return the conjugate transpose """ m, n = self.shape new = dok_matrix((n, m), dtype=self.dtype) for key, value in self.iteritems(): new[key[1], key[0]] = conj(value) return new | 867 |
def copy(self): new = dok_matrix() new.update(self) new.shape = self.shape return new | def copy(self): new = dok_matrix(self.shape, dtype=self.dtype) new.update(self) new.shape = self.shape return new | 868 |
def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix(self.shape, dtype=self.dtype) indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: new... | 869 |
def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self: num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newkey] = s... | 870 |
def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self: num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newkey] = s... | 871 |
def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self.keys(): num = searchsorted(cols_or_rows,... | def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self: num = searchsorted(cols_or_rows, key[1]... | 872 |
def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self.keys(): num = searchsorted(cols_or_rows,... | def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self: num = searchsorted(cols_or_rows, key[1]... | 873 |
def matvec(self, other): other = asarray(other) if other.shape[0] != self.shape[1]: raise ValueError, "dimensions do not match" new = [0]*self.shape[0] for key in self.keys(): new[int(key[0])] += self[key] * other[int(key[1]), ...] return array(new) | def matvec(self, other): other = asarray(other) if other.shape[0] != self.shape[1]: raise ValueError, "dimensions do not match" new = [0]*self.shape[0] for key in self: new[int(key[0])] += self[key] * other[int(key[1]), ...] return array(new) | 874 |
def rmatvec(self, other, conjugate=True): other = asarray(other) | def rmatvec(self, other, conjugate=True): other = asarray(other) | 875 |
def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = zeros(nzmax, dtype=self.dtype) colind = zeros(nzmax, dtype=self.dtype) # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each ... | 876 |
def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | 877 |
def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | 878 |
def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | 879 |
def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | 880 |
def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | 881 |
def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | 882 |
def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | 883 |
def todense(self, dtype=None): if dtype is None: dtype = 'd' new = zeros(self.shape, dtype=dtype) for key in self.keys(): ikey0 = int(key[0]) ikey1 = int(key[1]) new[ikey0, ikey1] = self[key] if amax(ravel(abs(new.imag))) == 0: new = new.real return new | def todense(self, dtype=None): if dtype is None: dtype = 'd' new = zeros(self.shape, dtype=dtype) for key in self: ikey0 = int(key[0]) ikey1 = int(key[1]) new[ikey0, ikey1] = self[key] if amax(ravel(abs(new.imag))) == 0: new = new.real return new | 884 |
def __init__(self, obj, ij_in, dims=None, nzmax=None, dtype=None): spmatrix.__init__(self) try: # Assume the first calling convention # assert len(ij) == 2 if len(ij_in) != 2: if isdense( ij_in ) and (ij_in.shape[1] == 2): ij = (ij_in[:,0], ij_in[:,1]) else: raise AssertionError else: ij = ij_in if dims is N... | def __init__(self, obj, ij_in, dims=None, nzmax=None, dtype=None): spmatrix.__init__(self) try: # Assume the first calling convention # assert len(ij) == 2 if len(ij_in) != 2: if isdense(ij_in) and (ij_in.shape[1] == 2): ij = (ij_in[:,0], ij_in[:,1]) else: raise AssertionError else: ij = ij_in if dims is Non... | 885 |
def isspmatrix_csr( x ): return isinstance(x, csr_matrix) | def isspmatrix_csr(x): return isinstance(x, csr_matrix) | 886 |
def isspmatrix_csc( x ): return isinstance(x, csc_matrix) | def isspmatrix_csc(x): return isinstance(x, csc_matrix) | 887 |
def isspmatrix_dok( x ): return isinstance(x, dok_matrix) | def isspmatrix_dok(x): return isinstance(x, dok_matrix) | 888 |
def isspmatrix_dod( x ): return isinstance(x, dod_matrix) | def isspmatrix_dod(x): return isinstance(x, dod_matrix) | 889 |
def isspmatrix_lnk( x ): return isinstance(x, lnk_matrix) | def isspmatrix_lnk(x): return isinstance(x, lnk_matrix) | 890 |
def isspmatrix_coo( x ): return isinstance(x, coo_matrix) | def isspmatrix_coo(x): return isinstance(x, coo_matrix) | 891 |
def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSR format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSC format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | 892 |
def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSR format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSR format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | 893 |
def solve(A, b, permc_spec=2): if not hasattr(A, 'tocsr') and not hasattr(A, 'tocsc'): raise ValueError, "sparse matrix must be able to return CSC format--"\ "A.tocsc()--or CSR format--A.tocsr()" if not hasattr(A, 'shape'): raise ValueError, "sparse matrix must be able to return shape (rows, cols) = A.shape" M, N = A.s... | def solve(A, b, permc_spec=2): if not hasattr(A, 'tocsr') and not hasattr(A, 'tocsc'): raise ValueError, "sparse matrix must be able to return CSC format--"\ "A.tocsc()--or CSR format--A.tocsr()" if not hasattr(A, 'shape'): raise ValueError, "sparse matrix must be able to return shape (rows, cols) = A.shape" M, N = A.s... | 894 |
def _ppf(self, q, a, b): return 1.0/(1+exp(-1.0/b*norm.ppf(q)-a)) | def _ppf(self, q, a, b): return 1.0/(1+exp(-1.0/b*norm.ppf(q)-a)) | 895 |
def lsim2(system, U, T, X0=None): """Simulate output of a continuous-time linear system, using ODE solver. Inputs: system -- an instance of the LTI class or a tuple describing the system. The following gives the number of elements in the tuple and the interpretation. 2 (num, den) 3 (zeros, poles, gain) 4 (A, B, C, D... | def lsim2(system, U, T, X0=None): """Simulate output of a continuous-time linear system, using ODE solver. Inputs: system -- an instance of the LTI class or a tuple describing the system. The following gives the number of elements in the tuple and the interpretation. 2 (num, den) 3 (zeros, poles, gain) 4 (A, B, C, D... | 896 |
def impulse(system, X0=None, T=None, N=None): """Impulse response of continuous-time system. Inputs: system -- an instance of the LTI class or a tuple with 2, 3, or 4 elements representing (num, den), (zero, pole, gain), or (A, B, C, D) representation of the system. X0 -- (optional, default = 0) inital state-vector. ... | def impulse(system, X0=None, T=None, N=None): """Impulse response of continuous-time system. Inputs: system -- an instance of the LTI class or a tuple with 2, 3, or 4 elements representing (num, den), (zero, pole, gain), or (A, B, C, D) representation of the system. X0 -- (optional, default = 0) inital state-vector. ... | 897 |
def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | 898 |
def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | 899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.