當前位置: 首頁>>代碼示例>>Python>>正文


Python scipy.dot方法代碼示例

本文整理匯總了Python中scipy.dot方法的典型用法代碼示例。如果您正苦於以下問題:Python scipy.dot方法的具體用法?Python scipy.dot怎麽用?Python scipy.dot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy的用法示例。


在下文中一共展示了scipy.dot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: b_orthonormalize

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def b_orthonormalize(B, blockVectorV,
                      blockVectorBV=None, retInvR=False):
    """Internal."""
    import scipy.linalg as sla
    if blockVectorBV is None:
        if B is not None:
            blockVectorBV = B(blockVectorV)
        else:
            blockVectorBV = blockVectorV  # Shared data!!!
    gramVBV = sp.dot(blockVectorV.T, blockVectorBV)
    gramVBV = sla.cholesky(gramVBV)
    gramVBV = sla.inv(gramVBV, overwrite_a=True)
    # gramVBV is now R^{-1}.
    blockVectorV = sp.dot(blockVectorV, gramVBV)
    if B is not None:
        blockVectorBV = sp.dot(blockVectorBV, gramVBV)

    if retInvR:
        return blockVectorV, blockVectorBV, gramVBV
    else:
        return blockVectorV, blockVectorBV 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:lobpcg.py

示例2: coupling_optim_garrick

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def coupling_optim_garrick(y,t):
	creation=s.zeros(n_bin)
	destruction=s.zeros(n_bin)
	#now I try to rewrite this in a more optimized way
	destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
	#the destruction of k-mers 
	
	for k in xrange(n_bin):
		kyn = (kernel*f_garrick[:,:,k])*y[:,s.newaxis]*y[s.newaxis,:]
		creation[k] = s.sum(kyn)
	creation=0.5*creation
	out=creation+destruction
	return out



#Now I work with the function for espressing smoluchowski equation when a uniform grid is used 
開發者ID:ActiveState,項目名稱:code,代碼行數:19,代碼來源:recipe-576547.py

示例3: coupling_optim

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def coupling_optim(y,t):
	creation=s.zeros(n_bin)
	destruction=s.zeros(n_bin)
	#now I try to rewrite this in a more optimized way
	destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
	#the destruction of k-mers 
	kyn = kernel*y[:,s.newaxis]*y[s.newaxis,:]
	for k in xrange(n_bin):
		creation[k] = s.sum(kyn[s.arange(k),k-s.arange(k)-1])
	creation=0.5*creation
	out=creation+destruction
	return out


#Now I go for the optimal optimization of the chi_{i,j,k} coefficients used by Garrick for
# dealing with a non-uniform grid. 
開發者ID:ActiveState,項目名稱:code,代碼行數:18,代碼來源:recipe-576547.py

示例4: generate_data

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def generate_data(N, S, L):

        # generate genetics
        G = 1.0 * (sp.rand(N, S) < 0.2)
        G -= G.mean(0)
        G /= G.std(0) * sp.sqrt(G.shape[1])

        # generate latent phenotypes
        Zg = sp.dot(G, sp.randn(G.shape[1], L))
        Zn = sp.randn(N, L)

        # generate variance exapleind
        vg = sp.linspace(0.8, 0, L)

        # rescale and sum
        Zg *= sp.sqrt(vg / Zg.var(0))
        Zn *= sp.sqrt((1 - vg) / Zn.var(0))
        Z = Zg + Zn

        return Z, G 
開發者ID:fpcasale,項目名稱:GPPVAE,代碼行數:22,代碼來源:gp.py

示例5: CalculateSchiultz

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def CalculateSchiultz(mol):
    """
    #################################################################
    Calculation of Schiultz number

    ---->Tsch(log value)

    Usage:

        result=CalculateSchiultz(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    Distance = numpy.array(Chem.GetDistanceMatrix(mol), "d")
    Adjacent = numpy.array(Chem.GetAdjacencyMatrix(mol), "d")
    VertexDegree = sum(Adjacent)

    return sum(scipy.dot((Distance + Adjacent), VertexDegree)) 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:23,代碼來源:topology.py

示例6: _quartimax_obj

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def _quartimax_obj(self, loadings):
        """
        Quartimax function objective.

        Parameters
        ----------
        loadings : array-like
            The loading matrix

        Returns
        -------
        gradient_dict : dict
            A dictionary with
            - grad : np.array
                The gradient.
            - criterion : float
                The value of the criterion for the objective.
        """
        gradient = -loadings**3
        criterion = -np.sum(np.diag(np.dot((loadings**2).T, loadings**2))) / 4
        return {'grad': gradient, 'criterion': criterion} 
開發者ID:EducationalTestingService,項目名稱:factor_analyzer,代碼行數:23,代碼來源:rotator.py

示例7: _oblimin_obj

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def _oblimin_obj(self, loadings):
        """
        The Oblimin function objective.

        Parameters
        ----------
        loadings : array-like
            The loading matrix

        Returns
        -------
        gradient_dict : dict
            A dictionary with
            - grad : np.array
                The gradient.
            - criterion : float
                The value of the criterion for the objective.
        """
        X = np.dot(loadings**2, np.eye(loadings.shape[1]) != 1)
        if (self.gamma != 0):
            p = loadings.shape[0]
            X = np.diag(np.full(1, p)) - np.dot(np.zeros((p, p)), X)
        gradient = loadings * X
        criterion = np.sum(loadings**2 * X) / 4
        return {'grad': gradient, 'criterion': criterion} 
開發者ID:EducationalTestingService,項目名稱:factor_analyzer,代碼行數:27,代碼來源:rotator.py

示例8: _quartimin_obj

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def _quartimin_obj(self, loadings):
        """
        Quartimin function objective.

        Parameters
        ----------
        loadings : array-like
            The loading matrix

        Returns
        -------
        gradient_dict : dict
            A dictionary with
            - grad : np.array
                The gradient.
            - criterion : float
                The value of the criterion for the objective.
        """
        X = np.dot(loadings**2, np.eye(loadings.shape[1]) != 1)
        gradient = loadings * X
        criterion = np.sum(loadings**2 * X) / 4
        return {'grad': gradient, 'criterion': criterion} 
開發者ID:EducationalTestingService,項目名稱:factor_analyzer,代碼行數:24,代碼來源:rotator.py

示例9: apply_givens

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def apply_givens(Q, v, k):
    """
    Apply the first k Givens rotations in Q to the vector v.

    Arguments
    ---------
        Q: list, list of consecutive 2x2 Givens rotations
        v: array, vector to apply the rotations to
        k: int, number of rotations to apply

    Returns
    -------
        v: array, that is changed in place.

    """

    for j in range(k):
        Qloc = Q[j]
        v[j:j+2] = scipy.dot(Qloc, v[j:j+2]) 
開發者ID:pygbe,項目名稱:pygbe,代碼行數:21,代碼來源:gmres.py

示例10: applyConstraints

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def applyConstraints(blockVectorV, factYBY, blockVectorBY, blockVectorY):
    """Internal. Changes blockVectorV in place."""
    gramYBV = sp.dot(blockVectorBY.T, blockVectorV)
    import scipy.linalg as sla
    tmp = sla.cho_solve(factYBY, gramYBV)
    blockVectorV -= sp.dot(blockVectorY, tmp) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:lobpcg.py

示例11: dir_cosines

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def dir_cosines(dir,coords=sp.identity(3)):
    """Returns a vector containing the direction cosines between vector dir, and
    the coordinate system coords. Default coordinate system is an orthonormal
    cartesian coordinate system."""
    cosines = sp.dot(coords,dir)/linalg.norm(dir)
    return cosines 
開發者ID:wolverton-research-group,項目名稱:qmpy,代碼行數:8,代碼來源:sound_waves.py

示例12: _auc_loss

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def _auc_loss(self, coef, X, y):
        fpr, tpr, _ = metrics.roc_curve(y, sp.dot(X, coef))
        return -metrics.auc(fpr, tpr) 
開發者ID:MaxHalford,項目名稱:xam,代碼行數:5,代碼來源:auc_regressor.py

示例13: predict

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def predict(self, X):
        return sp.dot(X, self.coef_) 
開發者ID:MaxHalford,項目名稱:xam,代碼行數:4,代碼來源:auc_regressor.py

示例14: score

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def score(self, X, y):
        fpr, tpr, _ = metrics.roc_curve(y, sp.dot(X, self.coef_))
        return metrics.auc(fpr, tpr) 
開發者ID:MaxHalford,項目名稱:xam,代碼行數:5,代碼來源:auc_regressor.py

示例15: cosine_similarity

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import dot [as 別名]
def cosine_similarity(a,b):
    a = mat(a)
    b = mat(b)

    c = dot(a,b.T)/linalg.norm(a)/linalg.norm(b)
    return c[0,0] 
開發者ID:sanmusunrise,項目名稱:ARNs,代碼行數:8,代碼來源:numpy_utils.py


注:本文中的scipy.dot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。