src/utils.py
def convmat(signal_size,kernel,dtype=_dtype):
	"""
	1D convolution (correlation) matrix with zero boundary conditions
	"""
	assert (kernel.size%2==1), "kernel is assumed to have odd number of elements"

	mat = sp.dia_matrix( (signal_size,signal_size), dtype=dtype )

	half_ker_size = kernel.size//2
	# correlation
	for i in range(-half_ker_size,half_ker_size+1):
		if ( kernel[half_ker_size+i]!=0 ):
			mat.setdiag(kernel[half_ker_size+i],i)
	# # convolution
	# for i in range(-half_ker_size,half_ker_size+1):
	# 	if ( kernel[half_ker_size-i]!=0 ):
	# 		mat.setdiag(kernel[half_ker_size-i],i)

	return mat

	1D convolution (correlation) matrix with zero boundary conditions
	
1D convolution (correlation) matrix with zero boundary conditions
1D convolution ( correlation ) matrix with zero boundary conditions
def convmat(signal_size,kernel,dtype=_dtype):
	assert (kernel.size%2==1), "kernel is assumed to have odd number of elements"
	mat = sp.dia_matrix( (signal_size,signal_size), dtype=dtype )
	half_ker_size = kernel.size//2
	for i in range(-half_ker_size,half_ker_size+1):
		if ( kernel[half_ker_size+i]!=0 ):
			mat.setdiag(kernel[half_ker_size+i],i)
	return mat
def convmat ( signal_size , kernel , dtype = _dtype ) : assert ( kernel . size % 2 == 1 ) , "kernel is assumed to have odd number of elements" mat = sp . dia_matrix ( ( signal_size , signal_size ) , dtype = dtype ) half_ker_size = kernel . size // 2 for i in range ( - half_ker_size , half_ker_size + 1 ) : if ( kernel [ half_ker_size + i ] != 0 ) : mat . setdiag ( kernel [ half_ker_size + i ] , i ) return mat
1D convolution (correlation) matrix with zero boundary conditions
1D convolution ( correlation ) matrix with zero boundary conditions
"""
	1D convolution (correlation) matrix with zero boundary conditions
	""" # correlation # # convolution # for i in range(-half_ker_size,half_ker_size+1): # 	if ( kernel[half_ker_size-i]!=0 ): # 		mat.setdiag(kernel[half_ker_size-i],i)
signal_size
kernel
dtype