zoukankan      html  css  js  c++  java
  • Python: ndarray operation

    Ndarray is most used data type in python, because many modules such as pylab, numpy use ndarray as default data type to undertake matrix operation. So using ndarray type of data will quickly accelerate the speed of python calculation.

    • Read part of indices from an ndarray matrix
      Suppose we have a matrix in ndarray type as M: 10*20, X:10, if we just wish to get the first dimension of this matrix we can set the code like this:
      M[0:3,:].shape=(3,20)
      X[0:3].shape=(3)
      The index begin with 0 end with 2, the last index 3 is not included!

    • reorder ndarray matrix
      x=numpy.array([0,1,2,3])
      y=numpy.array([[0,1,2,3],[0,2,4,6]])
      xf=numpy.fliplr(x)
      error Input must be >=2-d, this error might suggest that function fliplr can only work on matrix whose dimension bigger or equal than 2
      yf=array([][3,2,1,0],[6,4,2,0])

    • combine two ndarray
      A=numpy.concatenate([A1,A2])

  • 相关阅读:
    分布式事物的解决方法
    bootstrap的其他
    bootstrap表单控件
    多线程编程
    内存管理技术
    PrintWriter用法简析
    JSP内置对象
    Servlet学习应该注意的几点
    GPU渲染管线概述
    再说AutoComplete
  • 原文地址:https://www.cnblogs.com/docnan/p/7157788.html
Copyright © 2011-2022 走看看