numpy矩阵
2015-09-08 13:12
567 查看
np.matrix(np.identity(10))
[/code]
[/code]
[/code]
[/code]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.
来源: <https://docs.python.org/2/library/functions.html#cmp>
[/code]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).
来自为知笔记(Wiz)
In [20]: cmp(10,2) #cmp(x,y):
Out[20]: 1
In [21]: cmp(10,22)
Out[21]: -1
In [22]: cmp(10,10)
Out[22]: 0
[/code]
In [3]: import numpy as np
In [4]: a1=np.array([1,2,3],dtype=int)
In [5]: a2=np.array([[1,2,3],[2,3,4]])
In [6]: b1=np.zeros((2,3))
[/code]
In [7]: b1 [code]Out[7]:
array([[ 0., 0., 0.],
[ 0., 0., 0.]])
In [8]: a2
Out[8]:
array([[1, 2, 3],
[2, 3, 4]])
In [9]: a1
Out[9]: array([1, 2, 3])
[/code]
compile(source, filename, mode[, flags[, dont_inherit]])
[/code]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.
来源: <https://docs.python.org/2/library/functions.html#cmp>
divmod(a, b)
[/code]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).
来自为知笔记(Wiz)
相关文章推荐
- Python 低通滤波器
- Python 读取WAV音频文件 画频谱
- 再谈python的变量作用域
- python画完图后运行闪退解决办法
- 【python3.2机器学习环境搭建与配置】
- python对文件及文件夹的操作
- 非root用户安装Python 三方模块
- 简单 python爬虫 <2>
- python常用函数大总结
- python常用常用函数
- Python 主要模块和常用方法简览
- python 借助opencv实现Gabor滤波特征提取
- 零基础学python-12.4 while、for与range联合使用
- 零基础学python-12.4 while、for与range联合使用
- python os.path模块
- Python + uwcgi问题的解决
- 简单 python爬虫 <1>
- 妈妈再也不担心我的编码问题了。中文编码融汇贯通,windows,django,python,java,html 【转】
- Python支持的正则表达式元字符和语法
- Python多线程