private void exchange_rows(int row1, int row2) { Dictionary <int, double>[] contents = _contents; Dictionary <int, double> temp_row = contents[row1]; contents[row1] = contents[row2]; contents[row2] = temp_row; sparse_row[] row_objects = _row_objects; sparse_row temp_row_obj = row_objects[row1]; row_objects[row1] = row_objects[row2]; row_objects[row2] = temp_row_obj; }
public void clear(int new_rows = 0, int new_columns = 0) { if (new_rows <= 0) { if (_height <= 0) { throw new ArgumentException("Matrix size must be positive"); } new_rows = _height; new_columns = _initial_width; } else if (new_columns <= 0) { new_columns = new_rows; } int initial_width; _width = _initial_width = initial_width = new_columns; int height; Dictionary <int, double>[] contents; sparse_row[] row_objects; if (new_rows == _height) { height = _height; contents = _contents; row_objects = _row_objects; for (int cur_row = 0; cur_row < height; ++cur_row) { contents [cur_row].Clear(); row_objects[cur_row].set_width(initial_width); } } else { _height = height = new_rows; _contents = contents = new Dictionary <int, double> [height]; _row_objects = row_objects = new sparse_row[height]; for (int cur_row = 0; cur_row < height; ++cur_row) { contents [cur_row] = new Dictionary <int, double>(); row_objects[cur_row] = new sparse_row(contents[cur_row], initial_width); } } if (__index_array.Length < initial_width) { __index_array = new int[_initial_width]; } }