Guest User

Untitled

a guest
Nov 9th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. from math import cos, sin, pow, pi
  2. from numpy import zeros, array
  3.  
  4.  
  5. class Func:
  6.     def __init__(self, n):
  7.         self._f = zeros((n + 1, n + 1))
  8.         self._n = n
  9.         self._x = []
  10.         self._y = []
  11.         self._h = 1.0 / n
  12.         for i in range(0, self._n + 1):
  13.             self._x.append((1.0 / self._n) * i)
  14.             self._y.append((1.0 / self._n) * i)
  15.         self.CalcF()
  16.  
  17.     def CalcF(self):
  18.         const = 2 * pi * pi
  19.         for i in xrange(0, self._n + 1):
  20.             one = sin(pi * self._x[i])
  21.             for j in xrange(0, self._n + 1):
  22.                     two = sin(pi * self._y[j])
  23.                     self._f[i][j] = const * one * two
  24.         return self._f
  25.  
  26.     def X(self):
  27.         return self._x
  28.  
  29.     def Y(self):
  30.         return self._y
  31.  
  32.     def F(self):
  33.         return self._f
  34.  
  35.     def H(self):
  36.         return self._h
Advertisement
Add Comment
Please, Sign In to add comment