MCPcopy Create free account
hub / github.com/Axect/Peroxide / transpose

Method transpose

src/structure/sparse.rs:86–115  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

84 }
85
86 pub fn transpose(&self) -> Self {
87 let row = self.row;
88 let col = self.col;
89 let nnz = self.nnz;
90 let col_ptr = self.col_ptr();
91 let row_ics = self.row_ics();
92 let data = self.data();
93 let mut count = vec![0usize; row];
94 let mut result = Self::new(col, row, nnz);
95
96 for i in 0..col {
97 for &k in &row_ics[col_ptr[i]..col_ptr[i + 1]] {
98 count[k] += 1;
99 }
100 }
101 for (j, c) in count.iter_mut().enumerate().take(row) {
102 result.col_ptr[j + 1] = result.col_ptr[j] + *c;
103 *c = 0;
104 }
105 for i in 0..col {
106 for j in col_ptr[i]..col_ptr[i + 1] {
107 let k = row_ics[j];
108 let index = result.col_ptr[k] + count[k];
109 result.row_ics[index] = i;
110 result.data[index] = data[j];
111 count[k] += 1;
112 }
113 }
114 result
115 }
116
117 pub fn t(&self) -> Self {
118 self.transpose()

Callers 3

tMethod · 0.45
tMethod · 0.45
check_sparseFunction · 0.45

Calls 4

row_icsMethod · 0.80
dataMethod · 0.80
col_ptrMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected