Class: GSL::Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/gs2crmod/astrogk/gsl_tools.rb,
lib/gs2crmod/gsl_tools.rb

Defined Under Namespace

Classes: Complex

Instance Method Summary collapse

Instance Method Details

#forward_rows_r2ccObject



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/gs2crmod/astrogk/gsl_tools.rb', line 150

def forward_rows_r2cc
	gm = self.dup
	rows, cols = gm.shape
	if cols%2 == 0
		newcols = (cols+2)/2  
	else
		newcols = (cols+1)/2		
	end
	gm_cc = GSL::Matrix::Complex.alloc(rows, newcols)
		
	table = GSL.cache[[:fft_table, :real, cols]] ||= GSL::FFT::RealWavetable.alloc(cols)
	work = GSL.cache[[:fft_work, :real, cols]] ||= GSL::FFT::RealWorkspace.alloc(cols)
	row = GSL::Vector.alloc(cols)
	for i in 0...rows
		(0...cols).each{|j| row[j] = gm[i,j]}
# 		p i
# 		row = gm.get_row(i)
# 		vec_out = GSL::Vector::Complex.alloc(row.size)
# 		(0...row.size).each{|j| vec[j] = row[j]}
# 		if cols%2 == 0
# 			vec_out = vec.concat(vec.subvector(1, vec.size - 2).reverse.conjugate)
# 		else
# 			vec_out = vec.concat(vec.subvector(1, vec.size - 1).reverse.conjugate)
# 		end
		view = row.forward(table, work).halfcomplex_to_complex
		for j in 0...newcols
			gm_cc[i,j] =  view[j]
		end
	end
	return gm_cc
end

#move_cols_from_box_orderObject



143
144
145
146
147
# File 'lib/gs2crmod/astrogk/gsl_tools.rb', line 143

def move_cols_from_box_order
	rows, cols = self.shape
	gm1, gm2 = self.view(0,0, rows, (cols + 1)/2), self.view(0, (cols + 1)/2, rows, (cols - 1)/2)
	return gm2.horzcat(gm1)
end

#move_rows_from_box_orderObject



138
139
140
141
142
# File 'lib/gs2crmod/astrogk/gsl_tools.rb', line 138

def move_rows_from_box_order
	rows, cols = self.shape
	gm1, gm2 = self.view(0,0, (rows + 1)/2, cols), self.view((rows + 1)/2, 0,  (rows - 1)/2, cols)
	return gm2.vertcat(gm1)
end