File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ impl Solver {
137137 let n = new_index;
138138 let m = self . constraints . len ( ) ;
139139
140+ // println!("MMMMMMMMM: {}\n", m);
141+ // println!("NNNNNNNNN: {}\n", n);
142+
140143 let triplets: Vec < ( usize , usize , f64 ) > = old_triplets
141144 . into_par_iter ( )
142145 . map ( |( c_index, v_index, val) | {
Original file line number Diff line number Diff line change @@ -37,6 +37,19 @@ impl SpqrFactorization {
3737 n : usize ,
3838 ) -> Result < Self , String > {
3939 unsafe {
40+ if m == 0 || n == 0 {
41+
42+ unsafe {
43+ let ptr = eigen_create ( m as i32 , n as i32 ) ;
44+ return Ok ( SpqrFactorization {
45+ ptr : ptr,
46+ m : 0 ,
47+ n : 0 ,
48+ rank : 0 as usize ,
49+ } ) ;
50+ }
51+ }
52+
4053 let ptr = eigen_create ( m as i32 , n as i32 ) ;
4154
4255 let nnz = triplet. len ( ) ;
@@ -124,6 +137,9 @@ impl SpqrFactorization {
124137
125138 ///Complete solve function; determines what path of action to take depending on dimensions of matrix A
126139 pub fn solve ( & self , b : & DVector < f64 > ) -> Result < DVector < f64 > , String > {
140+ if self . n == 0 {
141+ return Ok ( DVector :: zeros ( 0 ) ) ;
142+ }
127143 if self . m >= self . n {
128144 return self . solve_regular ( b) ;
129145 } else {
@@ -236,6 +252,12 @@ impl SpqrFactorization {
236252 }
237253
238254 pub fn get_free_indices ( & self ) -> Result < DVector < f64 > , String > {
255+ if self . n == 0 {
256+ return Ok ( DVector :: zeros ( 0 ) ) ;
257+ }
258+ if self . m == 0 {
259+ return Ok ( DVector :: zeros ( self . n ) ) ;
260+ }
239261 let mut indices_mags = vec ! [ 0.0_f64 ; self . n] ;
240262 unsafe {
241263 eigen_get_free_indices ( self . ptr , indices_mags. as_mut_ptr ( ) ) ;
You can’t perform that action at this time.
0 commit comments