Thesis (Diplom) 
Indoor Localization of Mobile Devices Based on Wi-Fi Signals Using Raytracing Supported Algorithms
Place and Date of Creation
Turn right 90°Turn left 90°
  
  
  
  
  
 
Download single image
 
  

5.1. Third Party Libraries 65NumPy/SciPy/MatplotlibThe NumPy library is a major building block for the data structures of the frame-work. Numpy provides fast and efficient multi-dimensional array structures(ndar-rays) to the Python runtime. Additionally, a large number of linear algebra al-gorithms are available for the ndarrays due to linking against the BLAS/ATLASruntimes. With NumPy, tight loops of custom algorithms have to be handled withblockwise elementary operations over the ndarrays. A multitude of elementary op-erations likesum(),max(),abs(), are predefined and the method of choice if speedis crucial. But designing algorithms under that"blockwise" philosophy leads tosomewhat awkward formulated implementations. Therefore, only the ndarray datastructures, the infrastructure for file-IO and some filters for data preprocessing/datavisualization have been used. For example, the PHOTON output is loaded directlyinto the ndarrays with a single line of NumPy.By this choices, the implementations of the localization algorithms use only thendarray data structures and implement the tight loops in Cython, as this leads tomore flexibility and readability.The SciPy library supports NumPy by offering a large number of efficient numericalroutines working on the ndarray data structures. Especially the muti-dimensionalimage manipulation routines have proven to be very convenient during the thesis.And finally Matplotlib, a very flexible plotting library that integrates well with theNumPy data structures and provides publication quality figures. The combinationof these three libraries with Python scripting glue represents a more than adequatealternative to scientific computing environment like MATLAB.CythonCython is a Python -to-C compiler that was used for implementation of the localiza-tion algorithms. If the compiler is executed on pure Python code, the gains in theform of execution speed are minimal. The real performance improvements come fromhints that are given in the form of type annotations. Tight for-loops that use onlysuch typed variables are directly translated into their C equivalents and executedindependently of the Python Virtual Machine. This leads to speed ups of multipleorders of magnitude compared to code running in the Python VM. Furthermore,strong support for the ndarray data structures is given which results in a seamlessintegration into to NumPy/SciPy/Matplotlib ecosystem. Consequently, the SciPylibrary consists of a large number of Cython implemented routines.Another benefit of Cython comes by the flexible control over the threading behaviour.As mentioned in the introduction of this chapter, Python has no strong threadingsupport. Native OS threads are supported but the execution of the thread-specificPython byte-code is conducted serially due to a globally enforced interpreter Lock(GIL). The Cython library enables to control this locking behaviour. It allows torelease the Lock temporarily, and therefore let the Python VM continue on otherthreads. But this is only allowed if the implementation ensures not to access anyobjects from the Python runtime, during the lockless execution.This is exactly the case during the tight loops of the localization algorithms where