Mercurial > octave
comparison liboctave/dSparse.cc @ 5203:dbeafbc0ff64
[project @ 2005-03-15 00:58:55 by jwe]
author | jwe |
---|---|
date | Tue, 15 Mar 2005 00:58:56 +0000 |
parents | 57077d0ddc8e |
children | 90a9058de7e8 |
comparison
equal
deleted
inserted
replaced
5202:49de4e624020 | 5203:dbeafbc0ff64 |
---|---|
39 #include "dSparse.h" | 39 #include "dSparse.h" |
40 #include "oct-spparms.h" | 40 #include "oct-spparms.h" |
41 #include "SparsedbleLU.h" | 41 #include "SparsedbleLU.h" |
42 #include "SparseType.h" | 42 #include "SparseType.h" |
43 | 43 |
44 #ifdef HAVE_UMFPACK | |
44 // External UMFPACK functions in C | 45 // External UMFPACK functions in C |
45 extern "C" { | 46 extern "C" { |
46 #include "umfpack.h" | 47 #include <umfpack/umfpack.h> |
47 } | 48 } |
49 #endif | |
48 | 50 |
49 // Fortran functions we call. | 51 // Fortran functions we call. |
50 extern "C" | 52 extern "C" |
51 { | 53 { |
52 F77_RET_T | 54 F77_RET_T |
712 DET | 714 DET |
713 SparseMatrix::determinant (int& err, double& rcond, int) const | 715 SparseMatrix::determinant (int& err, double& rcond, int) const |
714 { | 716 { |
715 DET retval; | 717 DET retval; |
716 | 718 |
719 #ifdef HAVE_UMFPACK | |
717 int nr = rows (); | 720 int nr = rows (); |
718 int nc = cols (); | 721 int nc = cols (); |
719 | 722 |
720 if (nr == 0 || nc == 0 || nr != nc) | 723 if (nr == 0 || nc == 0 || nr != nc) |
721 { | 724 { |
819 else | 822 else |
820 retval = DET (d); | 823 retval = DET (d); |
821 } | 824 } |
822 } | 825 } |
823 } | 826 } |
827 #else | |
828 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
829 #endif | |
824 | 830 |
825 return retval; | 831 return retval; |
826 } | 832 } |
827 | 833 |
828 Matrix | 834 Matrix |
4669 { | 4675 { |
4670 // The return values | 4676 // The return values |
4671 void *Numeric; | 4677 void *Numeric; |
4672 err = 0; | 4678 err = 0; |
4673 | 4679 |
4680 #ifdef HAVE_UMFPACK | |
4674 // Setup the control parameters | 4681 // Setup the control parameters |
4675 Control = Matrix (UMFPACK_CONTROL, 1); | 4682 Control = Matrix (UMFPACK_CONTROL, 1); |
4676 double *control = Control.fortran_vec (); | 4683 double *control = Control.fortran_vec (); |
4677 umfpack_di_defaults (control); | 4684 umfpack_di_defaults (control); |
4678 | 4685 |
4764 } | 4771 } |
4765 | 4772 |
4766 if (err != 0) | 4773 if (err != 0) |
4767 umfpack_di_free_numeric (&Numeric); | 4774 umfpack_di_free_numeric (&Numeric); |
4768 | 4775 |
4776 #else | |
4777 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
4778 #endif | |
4779 | |
4769 return Numeric; | 4780 return Numeric; |
4770 } | 4781 } |
4771 | 4782 |
4772 Matrix | 4783 Matrix |
4773 SparseMatrix::fsolve (SparseType &mattype, const Matrix& b, int& err, | 4784 SparseMatrix::fsolve (SparseType &mattype, const Matrix& b, int& err, |
4801 typ = SparseType::Full; | 4812 typ = SparseType::Full; |
4802 } | 4813 } |
4803 | 4814 |
4804 if (typ == SparseType::Full) | 4815 if (typ == SparseType::Full) |
4805 { | 4816 { |
4817 #ifdef HAVE_UMFPACK | |
4806 Matrix Control, Info; | 4818 Matrix Control, Info; |
4807 void *Numeric = | 4819 void *Numeric = |
4808 factorize (err, rcond, Control, Info, sing_handler); | 4820 factorize (err, rcond, Control, Info, sing_handler); |
4809 | 4821 |
4810 if (err == 0) | 4822 if (err == 0) |
4860 | 4872 |
4861 umfpack_di_report_info (control, info); | 4873 umfpack_di_report_info (control, info); |
4862 | 4874 |
4863 umfpack_di_free_numeric (&Numeric); | 4875 umfpack_di_free_numeric (&Numeric); |
4864 } | 4876 } |
4877 #else | |
4878 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
4879 #endif | |
4865 } | 4880 } |
4866 else if (typ != SparseType::Hermitian) | 4881 else if (typ != SparseType::Hermitian) |
4867 (*current_liboctave_error_handler) ("incorrect matrix type"); | 4882 (*current_liboctave_error_handler) ("incorrect matrix type"); |
4868 } | 4883 } |
4869 | 4884 |
4901 typ = SparseType::Full; | 4916 typ = SparseType::Full; |
4902 } | 4917 } |
4903 | 4918 |
4904 if (typ == SparseType::Full) | 4919 if (typ == SparseType::Full) |
4905 { | 4920 { |
4921 #ifdef HAVE_UMFPACK | |
4906 Matrix Control, Info; | 4922 Matrix Control, Info; |
4907 void *Numeric = factorize (err, rcond, Control, Info, | 4923 void *Numeric = factorize (err, rcond, Control, Info, |
4908 sing_handler); | 4924 sing_handler); |
4909 | 4925 |
4910 if (err == 0) | 4926 if (err == 0) |
4992 | 5008 |
4993 umfpack_di_report_info (control, info); | 5009 umfpack_di_report_info (control, info); |
4994 | 5010 |
4995 umfpack_di_free_numeric (&Numeric); | 5011 umfpack_di_free_numeric (&Numeric); |
4996 } | 5012 } |
5013 #else | |
5014 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
5015 #endif | |
4997 } | 5016 } |
4998 else if (typ != SparseType::Hermitian) | 5017 else if (typ != SparseType::Hermitian) |
4999 (*current_liboctave_error_handler) ("incorrect matrix type"); | 5018 (*current_liboctave_error_handler) ("incorrect matrix type"); |
5000 } | 5019 } |
5001 | 5020 |
5033 typ = SparseType::Full; | 5052 typ = SparseType::Full; |
5034 } | 5053 } |
5035 | 5054 |
5036 if (typ == SparseType::Full) | 5055 if (typ == SparseType::Full) |
5037 { | 5056 { |
5057 #ifdef HAVE_UMFPACK | |
5038 Matrix Control, Info; | 5058 Matrix Control, Info; |
5039 void *Numeric = factorize (err, rcond, Control, Info, | 5059 void *Numeric = factorize (err, rcond, Control, Info, |
5040 sing_handler); | 5060 sing_handler); |
5041 | 5061 |
5042 if (err == 0) | 5062 if (err == 0) |
5111 | 5131 |
5112 umfpack_di_report_info (control, info); | 5132 umfpack_di_report_info (control, info); |
5113 | 5133 |
5114 umfpack_di_free_numeric (&Numeric); | 5134 umfpack_di_free_numeric (&Numeric); |
5115 } | 5135 } |
5136 #else | |
5137 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
5138 #endif | |
5116 } | 5139 } |
5117 else if (typ != SparseType::Hermitian) | 5140 else if (typ != SparseType::Hermitian) |
5118 (*current_liboctave_error_handler) ("incorrect matrix type"); | 5141 (*current_liboctave_error_handler) ("incorrect matrix type"); |
5119 } | 5142 } |
5120 | 5143 |
5153 typ = SparseType::Full; | 5176 typ = SparseType::Full; |
5154 } | 5177 } |
5155 | 5178 |
5156 if (typ == SparseType::Full) | 5179 if (typ == SparseType::Full) |
5157 { | 5180 { |
5181 #ifdef HAVE_UMFPACK | |
5158 Matrix Control, Info; | 5182 Matrix Control, Info; |
5159 void *Numeric = factorize (err, rcond, Control, Info, | 5183 void *Numeric = factorize (err, rcond, Control, Info, |
5160 sing_handler); | 5184 sing_handler); |
5161 | 5185 |
5162 if (err == 0) | 5186 if (err == 0) |
5254 | 5278 |
5255 umfpack_di_report_info (control, info); | 5279 umfpack_di_report_info (control, info); |
5256 | 5280 |
5257 umfpack_di_free_numeric (&Numeric); | 5281 umfpack_di_free_numeric (&Numeric); |
5258 } | 5282 } |
5283 #else | |
5284 (*current_liboctave_error_handler) ("UMFPACK not installed"); | |
5285 #endif | |
5259 } | 5286 } |
5260 else if (typ != SparseType::Hermitian) | 5287 else if (typ != SparseType::Hermitian) |
5261 (*current_liboctave_error_handler) ("incorrect matrix type"); | 5288 (*current_liboctave_error_handler) ("incorrect matrix type"); |
5262 } | 5289 } |
5263 | 5290 |