zoukankan      html  css  js  c++  java
  • numpy矩阵

    np.matrix(np.identity(10))
    1. In [20]: cmp(10,2) # cmp(x,y):
    2. Out[20]: 1
    3. In [21]: cmp(10,22)
    4. Out[21]: -1
    5. In [22]: cmp(10,10)
    6. Out[22]: 0
    1. In [3]: import numpy as np
    2. In [4]: a1=np.array([1,2,3],dtype=int)
    3. In [5]: a2=np.array([[1,2,3],[2,3,4]]) 
    4. In [6]: b1=np.zeros((2,3))  
    1. In [7]: b1
    2. Out[7]: 
    3. array([[ 0.,  0.,  0.],
    4.        [ 0.,  0.,  0.]])
    5. In [8]: a2
    6. Out[8]: 
    7. array([[1, 2, 3],
    8.        [2, 3, 4]])
    9. In [9]: a1
    10. Out[9]: array([1, 2, 3])

    1. compile(source, filename, mode[, flags[, dont_inherit]])

    Compile the source into a code or AST object. Code objects can be executed by an exec statement or evaluated by a call to eval().source can either be a Unicode string, a Latin-1 encoded string or an AST object. Refer to the ast module documentation for information on how to work with AST objects.


     

    1. divmod(a, b)

    Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using long division. With mixed operand types, the rules for binary arithmetic operators apply. For plain and long integers, the result is the same as (a // b, a % b). For floating point numbers the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less than that. In any case q * b + a % b is very close to a, if a % b is non-zero it has the same sign as b, and 0 <= abs(a % b) < abs(b).







  • 相关阅读:
    saltstack源码详解一
    linux的yum报错
    django restframework
    列表生成式
    面向对象的封装
    linux对于zombie的处理
    Flask学习目录
    #1_两数之和
    LeetCode入门
    Struts2(一)——基本使用
  • 原文地址:https://www.cnblogs.com/iathena/p/6b5ab7ad5a1cb9b4bb47f94a0246aa00.html
Copyright © 2011-2022 走看看