"""
@author: Fane
@file: numpyTest.py
@time:2017/8/9 21:15
"""
import numpy as np
def main():
lst=[[1,3,5],[2,4,6]]
print(type(lst))
np_lst=np.array(lst)
print (type(np_lst))
np_lst=np.array(lst,dtype=np.float)
print (np_lst.shape)
print (np_lst.ndim)
print (np_lst.dtype)
print (np_lst.itemsize)
print (np_lst.size)
print ("常用固定数组")
print (np.zeros([2,4]))
print (np.ones([3,5]))
print("Random:")
print (np.random.rand(2,4))
print (np.random.randn(2,4))
print (np.random.rand())
print ("RandInt:")
print (np.random.randint(1,10,3))
print (np.random.choice([10,20,30,2,6]))
print (np.random.beta(1,10,100))
print (np.arange(1,11))
print (np.arange(1,11).reshape([2,5]))
print (np.arange(1, 11).reshape([2, -1]))
list=np.arange(1,11).reshape([2,-1])
print ("exp:")
print(np.exp(list))
print(np.exp2(list))
print(np.sqrt(list))
print(np.sin(list))
print(np.log(list))
list2=np.array([[[1,2,3,4],[4,5,6,7]],
[[7,8,9,10],[10,11,12,13]],
[[14,15,16,17],[18,19,20,21]]])
print (list2.sum(axis=0))
print (list2.sum(axis=1))
print (list2.sum(axis=2))
print ("max and min")
print (list2.max(axis=2))
print (list2.min(axis=0))
ls1 = np.array([4,20,30,40])
ls2 = np.array([10,3,2,1])
print (ls1+ls2)
print (ls1-ls2)
print (ls1**2)
print(np.dot(ls1.reshape(2,2),ls2.reshape(2,2)))
print ("数组的拆分合并:")
print (np.concatenate((ls1,ls2),axis=0))
print (np.vstack((ls1,ls2)))
print (np.hstack((ls1,ls2)))
print (np.split(ls1,2))
print (np.copy(ls1))
from numpy.linalg import *
print (np.eye(3))
lst = np.array([[1,2],[3,4]])
print (inv(lst))
print (lst.transpose())
print (det(lst))
print (eig(lst))
y= np.array([[5.],[7.]])
print (solve(lst,y))
print (np.fft.fft(np.array([1,1,1,1,1,1,1,1,])))
print(np.corrcoef([1,0,1],[0,2,1]))
if __name__=="__main__":
main()