Function iaftemplate

Synopse

The iaftemplate function is used here just as an example of how to write a new function.

  • g = iaftemplate(f)
    • Output
      • g: ndarray, 1D, integer, size=graph_order. Array where ...
    • Input
      • f: ndarray, 2D, square. Adjacency matrix with ...

Description

The iaftemplate function does nothing useful but it shows an example for writing new function in this toolbox. In this field, you can describe what is important form the users to understand to properly use the function.

Function Code

1. def iaftemplate(f):
2.     import numpy as np
3. 
4.     H,W = f.shape
5.     return np.zeros((H,W))

Examples

Numerical example:

1. f = array( [[0,1,1,0,0,0,0,0,0],
2.             [1,0,0,0,0,0,0,1,0],
3.             [1,0,0,1,0,0,0,1,0],
4.             [0,0,0,0,0,1,1,0,0]], dtype=uint8)
1. import ia636 as ia
2. 
3. g = ia.iaftemplate(f)
4. print 'g: ', g
g:  [[ 0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.]]

Measuring time:

1. t = time.time()
2. f = ones((1000,1000))
3. g = ia.iaftemplate(f)
4. tend = time.time()
5. print 'Computational time (1k,1k) is {0:.2f} seconds.'.format(tend - t)
Computational time (1k,1k) is 0.01 seconds.

Equation

References

  • Van Rossum, Guido, and Barry Warsaw. "Style guide for python code." (2011). http://www.python.org/dev/peps/pep-0008
  • Lutz, Mark, and David Ascher. Learning python. O'Reilly Media, Incorporated, 2003.

See Also

  • iadft - Inverse Discrete Fourier Transform
  • iacos - Create a cosine wave image.

Contributions

  • R Lotufo, 25mai2014: improvements
  • Roberto Lotufo, 28oct2012: initial function.