comparison src/DLD-FUNCTIONS/sparse.cc @ 5760:8d7162924bd3

[project @ 2006-04-14 04:01:37 by jwe]
author jwe
date Fri, 14 Apr 2006 04:01:40 +0000
parents ce79d238f142
children 080c08b192d8
comparison
equal deleted inserted replaced
5759:ce79d238f142 5760:8d7162924bd3
147 147
148 if (is_sparse (arg)) 148 if (is_sparse (arg))
149 { 149 {
150 if (use_complex) 150 if (use_complex)
151 { 151 {
152 SparseComplexMatrix sm (((const octave_sparse_complex_matrix&) arg 152 SparseComplexMatrix sm = arg.sparse_complex_matrix_value ();
153 .get_rep ())
154 .sparse_complex_matrix_value ());
155 retval = new octave_sparse_complex_matrix (sm); 153 retval = new octave_sparse_complex_matrix (sm);
156 } 154 }
157 else if (use_bool) 155 else if (use_bool)
158 { 156 {
159 SparseBoolMatrix sm (((const octave_sparse_bool_matrix&) arg 157 SparseBoolMatrix sm = arg.sparse_bool_matrix_value ();
160 .get_rep ())
161 .sparse_bool_matrix_value ());
162 retval = new octave_sparse_bool_matrix (sm); 158 retval = new octave_sparse_bool_matrix (sm);
163 } 159 }
164 else 160 else
165 { 161 {
166 SparseMatrix sm (((const octave_sparse_matrix&) arg 162 SparseMatrix sm = arg.sparse_matrix_value ();
167 .get_rep ())
168 .sparse_matrix_value ());
169 retval = new octave_sparse_matrix (sm); 163 retval = new octave_sparse_matrix (sm);
170 } 164 }
171 } 165 }
172 else 166 else
173 { 167 {
378 @seealso{sparse}\n\ 372 @seealso{sparse}\n\
379 @end deftypefn") 373 @end deftypefn")
380 { 374 {
381 octave_value retval; 375 octave_value retval;
382 376
383 if (args.length() < 1) { 377 if (args.length() < 1)
384 print_usage ("full"); 378 {
385 return retval; 379 print_usage ("full");
386 } 380 return retval;
381 }
387 382
388 if (args(0).is_sparse_type ()) 383 if (args(0).is_sparse_type ())
389 { 384 {
390 if (args(0).type_name () == "sparse matrix") 385 if (args(0).type_name () == "sparse matrix")
391 retval = args(0).matrix_value (); 386 retval = args(0).matrix_value ();
428 } 423 }
429 } 424 }
430 425
431 if (dv(0) == 1) 426 if (dv(0) == 1)
432 { 427 {
433 retval(0)= I.transpose (); 428 retval(0) = I.transpose ();
434 retval(1)= J.transpose (); 429 retval(1) = J.transpose ();
435 retval(2)= S.transpose (); 430 retval(2) = S.transpose ();
436 } 431 }
437 else 432 else
438 { 433 {
439 retval(0)= I; 434 retval(0) = I;
440 retval(1)= J; 435 retval(1) = J;
441 retval(2)= S; 436 retval(2) = S;
442 } 437 }
443 retval(3)= (double) nr; 438 retval(3) = static_cast<double> (nr);
444 retval(4)= (double) nc; 439 retval(4) = static_cast<double> (nc);
440
445 return retval; 441 return retval;
446 } 442 }
447 443
448 static octave_value_list 444 static octave_value_list
449 sparse_find (const SparseComplexMatrix& v) 445 sparse_find (const SparseComplexMatrix& v)
469 } 465 }
470 } 466 }
471 467
472 if (dv(0) == 1) 468 if (dv(0) == 1)
473 { 469 {
474 retval(0)= I.transpose (); 470 retval(0) = I.transpose ();
475 retval(1)= J.transpose (); 471 retval(1) = J.transpose ();
476 retval(2)= S.transpose (); 472 retval(2) = S.transpose ();
477 } 473 }
478 else 474 else
479 { 475 {
480 retval(0)= I; 476 retval(0) = I;
481 retval(1)= J; 477 retval(1) = J;
482 retval(2)= S; 478 retval(2) = S;
483 } 479 }
484 retval(3)= (double) nr; 480 retval(3) = static_cast<double> (nr);
485 retval(4)= (double) nc; 481 retval(4) = static_cast<double> (nc);
482
486 return retval; 483 return retval;
487 } 484 }
488 485
489 static octave_value_list 486 static octave_value_list
490 sparse_find (const SparseBoolMatrix& v) 487 sparse_find (const SparseBoolMatrix& v)
510 } 507 }
511 } 508 }
512 509
513 if (dv(0) == 1) 510 if (dv(0) == 1)
514 { 511 {
515 retval(0)= I.transpose (); 512 retval(0) = I.transpose ();
516 retval(1)= J.transpose (); 513 retval(1) = J.transpose ();
517 retval(2)= S.transpose (); 514 retval(2) = S.transpose ();
518 } 515 }
519 else 516 else
520 { 517 {
521 retval(0)= I; 518 retval(0) = I;
522 retval(1)= J; 519 retval(1) = J;
523 retval(2)= S; 520 retval(2) = S;
524 } 521 }
525 retval(3)= (double) nr; 522 retval(3) = static_cast<double> (nr);
526 retval(4)= (double) nc; 523 retval(4) = static_cast<double> (nc);
524
527 return retval; 525 return retval;
528 } 526 }
529 527
530 // PKG_ADD: dispatch ("find", "spfind", "sparse matrix"); 528 // PKG_ADD: dispatch ("find", "spfind", "sparse matrix");
531 // PKG_ADD: dispatch ("find", "spfind", "sparse complex matrix"); 529 // PKG_ADD: dispatch ("find", "spfind", "sparse complex matrix");