Exemple #1
0
def D1_eo(N, h):
    """
	Compute the d1 matrix for mapping even functions to odd functions.
	"""

    DM = sincmats.deriv_mats(2 * N + 1, 1, h)
    D1 = DM[:, :, 0]

    #	Reflect and add values appropriatey

    return (D1[-N - 1:][:, -N - 1:] + hstack((zeros(
        (N + 1, 1)), fliplr(D1[-N - 1:][:, 0:N]))))
Exemple #2
0
def D2_e(N, h):
    """
	Compute the d2 matrix for even functions.
	"""

    DM = sincmats.deriv_mats(2 * N + 1, 2, h)
    D2 = DM[:, :, 1]

    #	Reflect and add values appropriatey

    return (D2[-N - 1:][:, -N - 1:] + hstack((zeros(
        (N + 1, 1)), fliplr(D2[-N - 1:][:, 0:N]))))
Exemple #3
0
def D1_eo(N,h):
	"""
	Compute the d1 matrix for mapping even functions to odd functions.
	"""
	
	DM = sincmats.deriv_mats(2 * N + 1, 1, h)
	D1 = DM[:, :, 0]

	#	Reflect and add values appropriatey

	return (D1[-N - 1:][:, -N - 1:] + 
		hstack((zeros((N + 1, 1)), fliplr(D1[-N - 1:][:, 0:N]))))
Exemple #4
0
def D2_e(N, h):
	"""
	Compute the d2 matrix for even functions.
	"""
	
	DM = sincmats.deriv_mats(2 * N + 1, 2, h)
	D2 = DM[:, :, 1]

	#	Reflect and add values appropriatey

	return (D2[-N-1:][:,-N-1:] + 
		hstack((zeros((N + 1, 1)), fliplr(D2[-N - 1:][:, 0:N]))))
Exemple #5
0
def D1_x_e(N,h):
	"""
	Compute the (1/x)(d/dx) matrix for even functions.
	"""
	
	x = points(N, h)
	k = arange(1, N + 1)

	DM =  sincmats.deriv_mats(2 * N + 1, 1, h)
	D1 = DM[:, :, 0]

	
	#	This row needs to be specially constructed
	
	zero_row = hstack(([-pi**2 / (3 * h**2)], -4 * ((-1)**k) / ((h**2) * k**2)))
		
	#	Reflect and add values appropriatey
	
	return vstack(( zero_row, ( dot(diag(1.0 / x[-N:]), D1[-N:][:,-N-1:]) + 
		hstack(( zeros((N, 1)), fliplr(dot(diag(1.0 / x[-N:] ), D1[-N:][:, 0:N])) )) ) ))
Exemple #6
0
def D1_x_e(N, h):
    """
	Compute the (1/x)(d/dx) matrix for even functions.
	"""

    x = points(N, h)
    k = arange(1, N + 1)

    DM = sincmats.deriv_mats(2 * N + 1, 1, h)
    D1 = DM[:, :, 0]

    #	This row needs to be specially constructed

    zero_row = hstack(
        ([-pi**2 / (3 * h**2)], -4 * ((-1)**k) / ((h**2) * k**2)))

    #	Reflect and add values appropriatey

    return vstack(
        (zero_row, (dot(diag(1.0 / x[-N:]), D1[-N:][:, -N - 1:]) + hstack(
            (zeros(
                (N, 1)), fliplr(dot(diag(1.0 / x[-N:]), D1[-N:][:, 0:N])))))))