관리-도구
편집 파일: matlib.cpython-37.pyc
B ��Fdp% � @ s� d dl mZmZmZ d dlZd dlmZmZ d dlT ej Z ej dd� Z e dddg7 Z dd d �Zddd�Zdd d�Z ddd�Zdd efdd�Zdd� Zdd� Zdd� ZdS )� )�division�absolute_import�print_functionN)�matrix�asmatrix)�*�rand�randn�repmat�Cc C s t jt| ||d�S )aP Return a new matrix of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int Shape of the empty matrix. dtype : data-type, optional Desired output data-type. order : {'C', 'F'}, optional Whether to store multi-dimensional data in row-major (C-style) or column-major (Fortran-style) order in memory. See Also -------- empty_like, zeros Notes ----- `empty`, unlike `zeros`, does not set the matrix values to zero, and may therefore be marginally faster. On the other hand, it requires the user to manually set all the values in the array, and should be used with caution. Examples -------- >>> import numpy.matlib >>> np.matlib.empty((2, 2)) # filled with random data matrix([[ 6.76425276e-320, 9.79033856e-307], [ 7.39337286e-309, 3.22135945e-309]]) #random >>> np.matlib.empty((2, 2), dtype=int) matrix([[ 6600475, 0], [ 6586976, 22740995]]) #random )�order)�ndarray�__new__r )�shape�dtyper � r �?/opt/alt/python37/lib64/python3.7/site-packages/numpy/matlib.py�empty s $r c C s t jt| ||d�}|�d� |S )a� Matrix of ones. Return a matrix of given shape and type, filled with ones. Parameters ---------- shape : {sequence of ints, int} Shape of the matrix dtype : data-type, optional The desired data-type for the matrix, default is np.float64. order : {'C', 'F'}, optional Whether to store matrix in C- or Fortran-contiguous order, default is 'C'. Returns ------- out : matrix Matrix of ones of given shape, dtype, and order. See Also -------- ones : Array of ones. matlib.zeros : Zero matrix. Notes ----- If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``, `out` becomes a single row matrix of shape ``(1,N)``. Examples -------- >>> np.matlib.ones((2,3)) matrix([[ 1., 1., 1.], [ 1., 1., 1.]]) >>> np.matlib.ones(2) matrix([[ 1., 1.]]) )r � )r r r �fill)r r r �ar r r �ones3 s ) r c C s t jt| ||d�}|�d� |S )a� Return a matrix of given shape and type, filled with zeros. Parameters ---------- shape : int or sequence of ints Shape of the matrix dtype : data-type, optional The desired data-type for the matrix, default is float. order : {'C', 'F'}, optional Whether to store the result in C- or Fortran-contiguous order, default is 'C'. Returns ------- out : matrix Zero matrix of given shape, dtype, and order. See Also -------- numpy.zeros : Equivalent array function. matlib.ones : Return a matrix of ones. Notes ----- If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``, `out` becomes a single row matrix of shape ``(1,N)``. Examples -------- >>> import numpy.matlib >>> np.matlib.zeros((2, 3)) matrix([[ 0., 0., 0.], [ 0., 0., 0.]]) >>> np.matlib.zeros(2) matrix([[ 0., 0.]]) )r r )r r r r )r r r r r r r �zeros` s ( r c C s2 t dg| dg |d�}t| | f|d�}||_|S )a� Returns the square identity matrix of given size. Parameters ---------- n : int Size of the returned identity matrix. dtype : data-type, optional Data-type of the output. Defaults to ``float``. Returns ------- out : matrix `n` x `n` matrix with its main diagonal set to one, and all other elements zero. See Also -------- numpy.identity : Equivalent array function. matlib.eye : More general matrix identity function. Examples -------- >>> import numpy.matlib >>> np.matlib.identity(3, dtype=int) matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) r r )r )�arrayr Zflat)�nr r �br r r �identity� s r c C s t t�| |||��S )a� Return a matrix with ones on the diagonal and zeros elsewhere. Parameters ---------- n : int Number of rows in the output. M : int, optional Number of columns in the output, defaults to `n`. k : int, optional Index of the diagonal: 0 refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal. dtype : dtype, optional Data-type of the returned matrix. Returns ------- I : matrix A `n` x `M` matrix where all elements are equal to zero, except for the `k`-th diagonal, whose values are equal to one. See Also -------- numpy.eye : Equivalent array function. identity : Square identity matrix. Examples -------- >>> import numpy.matlib >>> np.matlib.eye(3, k=1, dtype=float) matrix([[ 0., 1., 0.], [ 0., 0., 1.], [ 0., 0., 0.]]) )r �np�eye)r �M�kr r r r r � s %r c G s&