161 subroutine construct (this, mat_mode, threshold)
162 class(basematrix) :: this
163 integer,
intent(in) :: mat_mode
164 real(wp),
optional,
intent(in) :: threshold
168 if (
present(threshold))
then
169 this % threshold = threshold
174 this % matrix_mode = mat_mode
176 call this % construct_self
177 this % remove_row_column = .false.
178 this % constructed = .true.
187 subroutine exclude_row_column (this, row_column)
188 class(basematrix) :: this
189 integer,
intent(in) :: row_column
191 this % excluded_rowcol = row_column
192 if (this % excluded_rowcol > 0)
then
193 this % remove_row_column = .true.
203 subroutine initialize_matrix_structure (this, matrix_size, matrix_type, block_size)
204 class(basematrix) :: this
205 integer,
intent(in) :: matrix_size, matrix_type, block_size
208 this % initialized = .true.
209 this % matrix_dimension = matrix_size
210 this % matrix_type = matrix_type
211 this % block_size = block_size
213 if (this % remove_row_column .and. this % excluded_rowcol <= this % matrix_dimension)
then
214 this % matrix_dimension = this % matrix_dimension - 1
217 if (
allocated(this % diagonal))
deallocate(this % diagonal)
218 write (stdout,
"('Allocating dimension ',i12)") this % matrix_dimension
220 allocate(this % diagonal(this % matrix_dimension), stat = ierr)
226 call this % initialize_struct_self(this % matrix_dimension, this % matrix_type, this % block_size)
259 subroutine insert_matrix_element (this, i, j, coefficient, class_, thresh_)
260 class(basematrix) :: this
261 integer,
intent(in) :: i, j
262 real(wp),
intent(in) :: coefficient
263 integer,
intent(in),
optional :: class_
264 real(wp),
intent(in),
optional :: thresh_
266 integer ::
class, i_, j_
270 if (.not. this % initialized)
then
271 stop
"Matrix structure not initialized"
274 if (
present(thresh_))
then
277 thresh = this % threshold
280 if (
present(class_))
then
296 if (this % remove_row_column)
then
297 if (i_ == this % excluded_rowcol)
return
298 if (j_ == this % excluded_rowcol)
return
299 if (i_ > this % excluded_rowcol) i_ = i_ - 1
300 if (j_ > this % excluded_rowcol) j_ = j_ - 1
302 if (i == j)
call this % store_diagonal(i, coefficient)
303 if (abs(coefficient) < thresh)
return
305 call this % insert_matelem_self(i_, j_, coefficient,
class, thresh)
329 subroutine get_matrix_element (this, idx, i, j, coeff)
330 class(basematrix) :: this
331 integer,
intent(in) :: idx
332 integer,
intent(out) :: i, j
333 real(wp),
intent(out) :: coeff
335 if (this % check_bounds(idx))
then
336 call this % get_matelem_self(idx, i, j, coeff)