gps_pvt 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,7 @@
16
16
  %include std_common.i
17
17
  %include std_string.i
18
18
  %include exception.i
19
+ %include std_except.i
19
20
 
20
21
  //%import "SylphideMath.i"
21
22
 
@@ -29,7 +30,13 @@ type set_ ## name (const type &v) {
29
30
  %enddef
30
31
 
31
32
  #if !defined(SWIGIMPORTED)
32
- %header {
33
+ %exceptionclass native_exception;
34
+ %typemap(throws,noblock=1) native_exception {
35
+ $1.regenerate();
36
+ SWIG_fail;
37
+ }
38
+ %ignore native_exception;
39
+ %inline {
33
40
  struct native_exception : public std::exception {
34
41
  #if defined(SWIGRUBY)
35
42
  int state;
@@ -67,22 +74,15 @@ struct native_exception : public std::exception {
67
74
  }
68
75
  }
69
76
  #endif
70
- %exception each {
77
+ %typemap(in,numinputs=0) const void *check_block {
71
78
  #ifdef SWIGRUBY
72
79
  if(!rb_block_given_p()){
73
- return rb_enumeratorize(self, ID2SYM(rb_intern("each")), argc, argv);
80
+ return rb_enumeratorize(self, ID2SYM(rb_frame_callee()), argc, argv);
74
81
  }
75
82
  #endif
76
- try {
77
- $action
78
- } catch (const native_exception &e) {
79
- e.regenerate();
80
- SWIG_fail;
81
- } catch (const std::exception& e) {
82
- SWIG_exception(SWIG_RuntimeError, e.what());
83
- }
84
83
  }
85
- void each() const {
84
+ %catches(native_exception) each;
85
+ void each(const void *check_block) const {
86
86
  for(int i(0); i < 3; ++i){
87
87
  #ifdef SWIGRUBY
88
88
  int state;
@@ -48,9 +48,16 @@ inline std::string to_string(const T &value){
48
48
  %include std_common.i
49
49
  %include std_string.i
50
50
  %include exception.i
51
+ %include std_except.i
51
52
 
52
53
  #if !defined(SWIGIMPORTED)
53
- %header {
54
+ %exceptionclass native_exception;
55
+ %typemap(throws,noblock=1) native_exception {
56
+ $1.regenerate();
57
+ SWIG_fail;
58
+ }
59
+ %ignore native_exception;
60
+ %inline {
54
61
  struct native_exception : public std::exception {
55
62
  #if defined(SWIGRUBY)
56
63
  int state;
@@ -61,16 +68,6 @@ struct native_exception : public std::exception {
61
68
  #endif
62
69
  };
63
70
  }
64
- %exception {
65
- try {
66
- $action
67
- } catch (const native_exception &e) {
68
- e.regenerate();
69
- SWIG_fail;
70
- } catch (const std::exception& e) {
71
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
72
- }
73
- }
74
71
  #endif
75
72
 
76
73
  #ifdef SWIGRUBY
@@ -117,47 +114,82 @@ static std::string inspect_str(const VALUE &v){
117
114
  %import "SylphideMath.i"
118
115
  %import "Coordinate.i"
119
116
 
120
- %extend GPS_Time {
121
- %typemap(out) std::tm {
122
- %append_output(SWIG_From(int)($1.tm_year + 1900));
123
- %append_output(SWIG_From(int)($1.tm_mon + 1));
124
- %append_output(SWIG_From(int)($1.tm_mday));
125
- %append_output(SWIG_From(int)($1.tm_hour));
126
- %append_output(SWIG_From(int)($1.tm_min));
127
- %append_output(SWIG_From(int)($1.tm_sec));
117
+ %typemap(in,numinputs=0) const void *check_block {
118
+ #ifdef SWIGRUBY
119
+ if(!rb_block_given_p()){
120
+ return rb_enumeratorize(self, ID2SYM(rb_frame_callee()), argc, argv);
128
121
  }
129
- #if defined(SWIGRUBY)
130
- %typemap(in) const std::tm & (std::tm temp = {0}) {
131
- $1 = &temp;
132
- int *dst[] = {
133
- &(temp.tm_year),
134
- &(temp.tm_mon),
135
- &(temp.tm_mday),
136
- &(temp.tm_hour),
137
- &(temp.tm_min),
138
- &(temp.tm_sec),
139
- };
140
- int i_max(sizeof(dst) / sizeof(dst[0]));
141
- if(i_max > RARRAY_LEN($input)){i_max = RARRAY_LEN($input);}
122
+ #endif
123
+ }
124
+
125
+ %fragment(SWIG_From_frag(std::tm), "header", fragment=SWIG_From_frag(int)) {
126
+ SWIGINTERNINLINE SWIG_Object
127
+ SWIG_From_dec(std::tm)(const std::tm &value){
128
+ SWIG_Object res(SWIG_From(int)(value.tm_year + 1900));
129
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_mon + 1));
130
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_mday));
131
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_hour));
132
+ res = SWIG_AppendOutput(res, SWIG_From(int)(value.tm_min));
133
+ return SWIG_AppendOutput(res, SWIG_From(int)(value.tm_sec));
134
+ }
135
+ }
136
+ %fragment(SWIG_AsVal_frag(std::tm), "header", fragment=SWIG_AsVal_frag(int)){
137
+ SWIGINTERN int
138
+ SWIG_AsVal_dec(std::tm)(SWIG_Object obj, std::tm *val) {
139
+ #ifdef SWIGRUBY
140
+ int *dst[] = {
141
+ &(val->tm_year),
142
+ &(val->tm_mon),
143
+ &(val->tm_mday),
144
+ &(val->tm_hour),
145
+ &(val->tm_min),
146
+ &(val->tm_sec),
147
+ };
148
+ if(RB_TYPE_P(obj, T_ARRAY)){
149
+ int i_max(RARRAY_LEN(obj));
150
+ if(i_max > sizeof(dst) / sizeof(dst[0])){return SWIG_ERROR;}
151
+ VALUE obj_i;
152
+ int v;
142
153
  for(int i(0); i < i_max; ++i){
143
- SWIG_Object obj = rb_ary_entry($input, i);
144
- int v;
145
- if(SWIG_IsOK(SWIG_AsVal(int)(obj, &v))){
146
- if(dst[i] == &(temp.tm_year)){
154
+ obj_i = RARRAY_AREF(obj, i);
155
+ if(SWIG_IsOK(SWIG_AsVal(int)(obj_i, &v))){
156
+ if(dst[i] == &(val->tm_year)){
147
157
  *dst[i] = v - 1900;
148
- }else if(dst[i] == &(temp.tm_mon)){
158
+ }else if(dst[i] == &(val->tm_mon)){
149
159
  *dst[i] = v - 1;
150
160
  }else{
151
161
  *dst[i] = v;
152
162
  }
153
163
  }else{
154
- SWIG_exception(SWIG_TypeError, "int is expected");
164
+ SWIG_exception(SWIG_TypeError,
165
+ std::string("Unexpected input [").append(std::to_string(i)).append("]: ")
166
+ .append(inspect_str(obj_i)).c_str());
155
167
  }
156
168
  }
169
+ return SWIG_OK;
157
170
  }
158
- %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) const std::tm & {
159
- $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
171
+ #endif
172
+ return SWIG_ERROR;
173
+ }
174
+ }
175
+ %typemap(out, fragment=SWIG_From_frag(std::tm)) std::tm {
176
+ $result = SWIG_From(std::tm)($1);
177
+ }
178
+ %typemap(in, fragment=SWIG_AsVal_frag(std::tm)) const std::tm & (std::tm temp = {0}) {
179
+ if(SWIG_AsVal(std::tm)($input, $1 = &temp) != SWIG_OK){
180
+ SWIG_exception(SWIG_TypeError, "int[1..6] is expected");
160
181
  }
182
+ }
183
+ %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) const std::tm & {
184
+ #ifdef SWIGRUBY
185
+ $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
186
+ #else
187
+ $1 = 0;
188
+ #endif
189
+ }
190
+
191
+ %extend GPS_Time {
192
+ #if defined(SWIGRUBY)
161
193
  %typemap(varout,fragment="SWIG_Traits_frag(FloatT)") leap_second_event_t [] {
162
194
  $result = rb_ary_new2(sizeof($1) / sizeof($1[0]));
163
195
  for(std::size_t i(0); i < sizeof($1) / sizeof($1[0]); ++i){
@@ -275,11 +307,12 @@ struct GPS_Ionospheric_UTC_Parameters : public GPS_SpaceNode<FloatT>::Ionospheri
275
307
  MAKE_ACCESSOR(WN_LSF, unsigned int);
276
308
  MAKE_ACCESSOR(DN, unsigned int);
277
309
  MAKE_ACCESSOR(delta_t_LSF, int);
310
+ %catches(std::invalid_argument) parse;
278
311
  static GPS_Ionospheric_UTC_Parameters<FloatT> parse(const unsigned int buf[10]){
279
312
  typedef typename GPS_SpaceNode<FloatT>
280
313
  ::BroadcastedMessage<unsigned int, 30> parser_t;
281
314
  if((parser_t::subframe_id(buf) != 4) || (parser_t::sv_page_id(buf) != 56)){
282
- throw std::runtime_error("Not valid data");
315
+ throw std::invalid_argument("Not valid data");
283
316
  }
284
317
  typename GPS_SpaceNode<FloatT>::Ionospheric_UTC_Parameters::raw_t raw;
285
318
  raw.update<2, 0>(buf);
@@ -571,7 +604,7 @@ struct SBAS_Ephemeris : public SBAS_SpaceNode<FloatT>::SatelliteProperties::Ephe
571
604
 
572
605
  MAKE_ACCESSOR(WN, unsigned int);
573
606
  MAKE_ACCESSOR(t_0, FloatT);
574
- MAKE_ACCESSOR(URA, int);
607
+ MAKE_ACCESSOR(URA, FloatT);
575
608
  MAKE_ACCESSOR( x, FloatT); MAKE_ACCESSOR( y, FloatT); MAKE_ACCESSOR( z, FloatT);
576
609
  MAKE_ACCESSOR( dx, FloatT); MAKE_ACCESSOR( dy, FloatT); MAKE_ACCESSOR( dz, FloatT);
577
610
  MAKE_ACCESSOR(ddx, FloatT); MAKE_ACCESSOR(ddy, FloatT); MAKE_ACCESSOR(ddz, FloatT);
@@ -654,6 +687,10 @@ struct GLONASS_Ephemeris
654
687
  bool is_consistent() const {
655
688
  return has_string == 0x1F;
656
689
  }
690
+ bool is_in_range(const GPS_Time<FloatT> &t) const {
691
+ // "invalidate()" is used to make raw and converted data inconsistent.
692
+ return eph_t::is_valid(t);
693
+ }
657
694
  bool is_valid(const GPS_Time<FloatT> &t) const {
658
695
  return is_consistent() && eph_t::is_valid(t);
659
696
  }
@@ -800,10 +837,6 @@ struct GLONASS_Ephemeris
800
837
  %rename("valid?") is_valid;
801
838
  %rename("in_range?") is_in_range;
802
839
  #endif
803
- bool is_in_range(const GPS_Time<FloatT> &t) const {
804
- // "invalidate()" is used to make raw and converted data inconsistent.
805
- return self->is_valid(t);
806
- }
807
840
  }
808
841
 
809
842
  %extend GLONASS_SpaceNode {
@@ -894,11 +927,12 @@ struct GPS_User_PVT
894
927
  ERROR_VELOCITY_LS,
895
928
  };
896
929
  int error_code() const {return (int)(base_t::error_code);}
897
- const GPS_Time<FloatT> &receiver_time() const {return base_t::receiver_time;}
898
- const System_XYZ<FloatT, WGS84> &xyz() const {return base_t::user_position.xyz;}
899
- const System_LLH<FloatT, WGS84> &llh() const {return base_t::user_position.llh;}
930
+ // Returning Type because returning const Type & causes reference problem after GC
931
+ GPS_Time<FloatT> receiver_time() const {return base_t::receiver_time;}
932
+ System_XYZ<FloatT, WGS84> xyz() const {return base_t::user_position.xyz;}
933
+ System_LLH<FloatT, WGS84> llh() const {return base_t::user_position.llh;}
900
934
  const FloatT &receiver_error() const {return base_t::receiver_error;}
901
- const System_ENU<FloatT, WGS84> &velocity() const {return base_t::user_velocity_enu;}
935
+ System_ENU<FloatT, WGS84> velocity() const {return base_t::user_velocity_enu;}
902
936
  const FloatT &receiver_error_rate() const {return base_t::receiver_error_rate;}
903
937
  const FloatT &gdop() const {return base_t::dop.g;}
904
938
  const FloatT &pdop() const {return base_t::dop.p;}
@@ -975,23 +1009,9 @@ struct GPS_User_PVT
975
1009
  %extend GPS_Measurement {
976
1010
  %ignore items_t;
977
1011
  %ignore items;
978
- %exception each {
979
- #ifdef SWIGRUBY
980
- if(!rb_block_given_p()){
981
- return rb_enumeratorize(self, ID2SYM(rb_intern("each")), argc, argv);
982
- }
983
- #endif
984
- try {
985
- $action
986
- } catch (const native_exception &e) {
987
- e.regenerate();
988
- SWIG_fail;
989
- } catch (const std::exception& e) {
990
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
991
- }
992
- }
993
1012
  %fragment(SWIG_Traits_frag(FloatT));
994
- void each() const {
1013
+ %catches(native_exception) each;
1014
+ void each(const void *check_block) const {
995
1015
  for(typename GPS_Measurement<FloatT>::items_t::const_iterator
996
1016
  it(self->items.begin()), it_end(self->items.end());
997
1017
  it != it_end; ++it){
@@ -1322,6 +1342,7 @@ struct HookableSolver : public BaseT {
1322
1342
  %ignore user_correctors;
1323
1343
  %immutable hooks;
1324
1344
  %ignore mark;
1345
+ %catches(native_exception, std::runtime_error) solve;
1325
1346
  %fragment("hook"{GPS_Solver<FloatT>}, "header",
1326
1347
  fragment=SWIG_From_frag(int),
1327
1348
  fragment=SWIG_Traits_frag(FloatT),
@@ -1385,7 +1406,7 @@ struct HookableSolver : public BaseT {
1385
1406
  if((!RB_TYPE_P(res_hook, T_ARRAY))
1386
1407
  || (RARRAY_LEN(res_hook) != prop_items)){
1387
1408
  throw std::runtime_error(
1388
- std::string("[d * ").append(std::to_string(prop_items))
1409
+ std::string("relative_property() returning [d * ").append(std::to_string(prop_items))
1389
1410
  .append("] is expected (d: " %str(FloatT) "), however ")
1390
1411
  .append(inspect_str(res_hook)));
1391
1412
  }
@@ -1393,7 +1414,7 @@ struct HookableSolver : public BaseT {
1393
1414
  VALUE v(RARRAY_AREF(res_hook, i));
1394
1415
  if(!SWIG_IsOK(swig::asval(v, &res.values[i]))){
1395
1416
  throw std::runtime_error(
1396
- std::string(%str(FloatT) " is exepcted, however ")
1417
+ std::string("relative_property() returning " %str(FloatT) " is exepcted, however ")
1397
1418
  .append(inspect_str(v))
1398
1419
  .append(" @ [").append(std::to_string(i)).append("]"));
1399
1420
  }
@@ -1516,7 +1537,7 @@ struct HookableSolver : public BaseT {
1516
1537
  list_t input;
1517
1538
  if(update){
1518
1539
  if(!RB_TYPE_P(hash, T_HASH)){
1519
- throw std::runtime_error(
1540
+ throw std::invalid_argument(
1520
1541
  std::string("Hash is expected, however ").append(inspect_str(hash)));
1521
1542
  }
1522
1543
  for(std::size_t i(0); i < sizeof(k_root) / sizeof(k_root[0]); ++i){
@@ -1594,6 +1615,7 @@ struct HookableSolver : public BaseT {
1594
1615
  VALUE get_correction() const {
1595
1616
  return const_cast<GPS_Solver<FloatT> *>(self)->update_correction(false, Qnil);
1596
1617
  }
1618
+ %catches(std::invalid_argument) set_correction;
1597
1619
  VALUE set_correction(VALUE hash){
1598
1620
  return self->update_correction(true, hash);
1599
1621
  }
@@ -1824,23 +1846,9 @@ struct GPS_Solver
1824
1846
  %fragment(SWIG_From_frag(char));
1825
1847
 
1826
1848
  %extend RINEX_Observation {
1827
- %exception read {
1828
- #ifdef SWIGRUBY
1829
- if(!rb_block_given_p()){
1830
- return rb_enumeratorize(self, ID2SYM(rb_intern("read")), argc, argv);
1831
- }
1832
- #endif
1833
- try {
1834
- $action
1835
- } catch (const native_exception &e) {
1836
- e.regenerate();
1837
- SWIG_fail;
1838
- } catch (const std::exception& e) {
1839
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
1840
- }
1841
- }
1842
1849
  %fragment(SWIG_Traits_frag(FloatT));
1843
- static void read(const char *fname) {
1850
+ %catches(native_exception) read;
1851
+ static void read(const char *fname, const void *check_block) {
1844
1852
  std::fstream fin(fname, std::ios::in | std::ios::binary);
1845
1853
  struct reader_t : public RINEX_OBS_Reader<FloatT> {
1846
1854
  typedef RINEX_OBS_Reader<FloatT> super_t;
@@ -31,9 +31,17 @@
31
31
  %include std_string.i
32
32
  //%include std_vector.i
33
33
  %include exception.i
34
+ %include std_except.i
34
35
 
36
+ %ignore native_exception;
35
37
  #if !defined(SWIGIMPORTED)
36
- %header {
38
+ %exceptionclass native_exception;
39
+ %typemap(throws,noblock=1) native_exception {
40
+ $1.regenerate();
41
+ SWIG_fail;
42
+ }
43
+ %ignore native_exception;
44
+ %inline {
37
45
  struct native_exception : public std::exception {
38
46
  #if defined(SWIGRUBY)
39
47
  int state;
@@ -44,16 +52,6 @@ struct native_exception : public std::exception {
44
52
  #endif
45
53
  };
46
54
  }
47
- %exception {
48
- try {
49
- $action
50
- } catch (const native_exception &e) {
51
- e.regenerate();
52
- SWIG_fail;
53
- } catch (const std::exception& e) {
54
- SWIG_exception_fail(SWIG_RuntimeError, e.what());
55
- }
56
- }
57
55
  #endif
58
56
 
59
57
  %define MAKE_ACCESSOR(name, type)
@@ -548,7 +546,7 @@ struct MatrixUtil {
548
546
  #if defined(SWIGRUBY)
549
547
  static const each_which_t &sym2each_which(const VALUE &value){
550
548
  if(!RB_TYPE_P(value, T_SYMBOL)){
551
- std::runtime_error("Symbol is required");
549
+ std::invalid_argument("Symbol is required");
552
550
  }
553
551
  static const struct {
554
552
  VALUE sym;
@@ -567,7 +565,7 @@ struct MatrixUtil {
567
565
  if(++i >= (sizeof(cmp) / sizeof(cmp[0]))){break;}
568
566
  }
569
567
  if(i >= (sizeof(cmp) / sizeof(cmp[0]))){
570
- std::runtime_error("Unknown enumerate direction");
568
+ std::invalid_argument("Unknown enumerate direction");
571
569
  }
572
570
  return cmp[i].which;
573
571
  }
@@ -602,16 +600,16 @@ struct MatrixUtil {
602
600
  if(value && RB_TYPE_P(*value, T_ARRAY)){
603
601
  if(RB_TYPE_P(RARRAY_AREF(*value, 0), T_ARRAY)){ // [[r0c0, r0c1, ...], ...]
604
602
  if((unsigned int)RARRAY_LEN(*value) < r){
605
- throw std::runtime_error("Length is too short");
603
+ throw std::invalid_argument("Length is too short");
606
604
  }
607
605
  VALUE value_r;
608
606
  for(; i_elm < len; i_elm++){
609
607
  if(j == 0){
610
608
  value_r = RARRAY_AREF(*value, i);
611
609
  if(!RB_TYPE_P(value_r, T_ARRAY)){
612
- throw std::runtime_error("double array [[...], ...] is required");
610
+ throw std::invalid_argument("double array [[...], ...] is required");
613
611
  }else if((unsigned int)RARRAY_LEN(value_r) < c){
614
- throw std::runtime_error("Length is too short");
612
+ throw std::invalid_argument("Length is too short");
615
613
  }
616
614
  }
617
615
  v_elm = RARRAY_AREF(value_r, j);
@@ -620,7 +618,7 @@ struct MatrixUtil {
620
618
  }
621
619
  }else{ // [r0c0, r0c1, ...]
622
620
  if((unsigned int)RARRAY_LEN(*value) < len){
623
- throw std::runtime_error("Length is too short");
621
+ throw std::invalid_argument("Length is too short");
624
622
  }
625
623
  for(; i_elm < len; i_elm++){
626
624
  v_elm = RARRAY_AREF(*value, i_elm);
@@ -647,7 +645,7 @@ struct MatrixUtil {
647
645
  if(replaced && (i_elm < len)){
648
646
  std::stringstream s;
649
647
  s << "Unexpected input [" << i << "," << j << "]: ";
650
- throw std::runtime_error(s.str().append(inspect_str(v_elm)));
648
+ throw std::invalid_argument(s.str().append(inspect_str(v_elm)));
651
649
  }
652
650
  #endif
653
651
  return replaced;
@@ -668,6 +666,12 @@ struct MatrixUtil {
668
666
  %}
669
667
 
670
668
  %extend Matrix_Frozen {
669
+ %catches(std::logic_error) trace;
670
+ %catches(std::out_of_range) partial;
671
+ %catches(std::out_of_range) rowVector;
672
+ %catches(std::out_of_range) columnVector;
673
+ %catches(std::logic_error, std::runtime_error) determinant;
674
+
671
675
  T __getitem__(const unsigned int &row, const unsigned int &column) const {
672
676
  return ($self)->operator()(row, column);
673
677
  }
@@ -705,6 +709,7 @@ struct MatrixUtil {
705
709
  return (Matrix<T, Array2D_Dense<T> >)(($self)->operator-());
706
710
  }
707
711
 
712
+ %catches(std::invalid_argument) operator+;
708
713
  template <class T2, class Array2D_Type2, class ViewType2>
709
714
  Matrix<T, Array2D_Dense<T> > operator+(
710
715
  const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix) const {
@@ -715,6 +720,7 @@ struct MatrixUtil {
715
720
  return (Matrix<T, Array2D_Dense<T> >)(($self)->operator+(scalar));
716
721
  }
717
722
 
723
+ %catches(std::invalid_argument) operator-;
718
724
  template <class T2, class Array2D_Type2, class ViewType2>
719
725
  Matrix<T, Array2D_Dense<T> > operator-(
720
726
  const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix) const {
@@ -727,7 +733,8 @@ struct MatrixUtil {
727
733
 
728
734
  template <class T2, class Array2D_Type2, class ViewType2>
729
735
  Matrix<T, Array2D_Dense<T> > operator*(
730
- const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix) const {
736
+ const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix)
737
+ const throw(std::invalid_argument) {
731
738
  return (Matrix<T, Array2D_Dense<T> >)(($self)->operator*(matrix));
732
739
  }
733
740
  INSTANTIATE_MATRIX_FUNC(operator*, __mul__);
@@ -750,6 +757,7 @@ struct MatrixUtil {
750
757
  Matrix<T, Array2D_Dense<T> > &output_R {
751
758
  %append_output(SWIG_NewPointerObj((new $*1_ltype(*$1)), $1_descriptor, SWIG_POINTER_OWN));
752
759
  }
760
+ %catches(std::logic_error, std::runtime_error) lup;
753
761
  void lup(
754
762
  Matrix<T, Array2D_Dense<T> > &output_L,
755
763
  Matrix<T, Array2D_Dense<T> > &output_U,
@@ -775,6 +783,7 @@ struct MatrixUtil {
775
783
  output_U = LU.partial($self->rows(), $self->columns(), 0, $self->rows()).copy();
776
784
  output_P = buf.P();
777
785
  }
786
+ %catches(std::logic_error) ud;
778
787
  void ud(
779
788
  Matrix<T, Array2D_Dense<T> > &output_U,
780
789
  Matrix<T, Array2D_Dense<T> > &output_D) const {
@@ -790,12 +799,14 @@ struct MatrixUtil {
790
799
  output_R = QR.partial($self->rows(), $self->columns(), 0, $self->rows()).copy();
791
800
  }
792
801
 
802
+ %catches(std::logic_error, std::runtime_error) inverse;
793
803
  Matrix<T, Array2D_Dense<T> > inverse() const {
794
804
  return (Matrix<T, Array2D_Dense<T> >)(($self)->inverse());
795
805
  }
796
806
  template <class T2, class Array2D_Type2, class ViewType2>
797
807
  Matrix<T, Array2D_Dense<T> > operator/(
798
- const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix) const {
808
+ const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix)
809
+ const throw(std::logic_error, std::runtime_error) {
799
810
  return (Matrix<T, Array2D_Dense<T> >)(($self)->operator/(matrix));
800
811
  }
801
812
  INSTANTIATE_MATRIX_FUNC(operator/, __div__);
@@ -835,7 +846,7 @@ struct MatrixUtil {
835
846
  if(assign && !SWIG_IsOK(swig::asval(v, dst))){
836
847
  std::stringstream s;
837
848
  s << "Unknown input (T expected) [" << i << "," << j << "]: ";
838
- throw std::runtime_error(s.str().append(inspect_str(v)));
849
+ throw std::invalid_argument(s.str().append(inspect_str(v)));
839
850
  }
840
851
  }
841
852
  static void matrix_yield(
@@ -890,10 +901,11 @@ struct MatrixUtil {
890
901
  %typemap(in) const typename MatrixUtil::each_which_t &each_which {
891
902
  try{
892
903
  $1 = &const_cast<typename MatrixUtil::each_which_t &>(MatrixUtil::sym2each_which($input));
893
- }catch(std::runtime_error &e){
894
- SWIG_exception(SWIG_TypeError, e.what());
904
+ }catch(std::invalid_argument &e){
905
+ SWIG_exception(SWIG_ValueError, e.what());
895
906
  }
896
907
  }
908
+ %catches(native_exception) each;
897
909
  const Matrix_Frozen<T, Array2D_Type, ViewType> &each(
898
910
  void (*each_func)(
899
911
  const T &src, T *dst,
@@ -904,6 +916,7 @@ struct MatrixUtil {
904
916
  }
905
917
  %alias each "each_with_index";
906
918
 
919
+ %catches(native_exception, std::invalid_argument) map;
907
920
  Matrix<T, Array2D_Dense<T> > map(
908
921
  void (*each_func)(
909
922
  const T &src, T *dst,
@@ -950,7 +963,8 @@ MAKE_TO_S(Matrix_Frozen)
950
963
  %fragment(SWIG_Traits_frag(T));
951
964
 
952
965
  Matrix(const unsigned int &rows, const unsigned int &columns,
953
- const void *replacer = NULL){
966
+ const void *replacer = NULL)
967
+ throw(native_exception, std::invalid_argument) {
954
968
  Matrix<T, Array2D_Type, ViewType> res(rows, columns);
955
969
  MatrixUtil::replace(res, replacer);
956
970
  return new Matrix<T, Array2D_Type, ViewType>(res);
@@ -964,7 +978,7 @@ MAKE_TO_S(Matrix_Frozen)
964
978
  #if defined(SWIGRUBY)
965
979
  %fragment(SWIG_AsVal_frag(unsigned int));
966
980
  %fragment("check_value"{unsigned int});
967
- Matrix(const void *replacer){
981
+ Matrix(const void *replacer) throw(native_exception, std::invalid_argument) {
968
982
  const SWIG_Object *value(static_cast<const SWIG_Object *>(replacer));
969
983
  static const ID id_r(rb_intern("row_size")), id_c(rb_intern("column_size"));
970
984
  if(value && RB_TYPE_P(*value, T_ARRAY) && RB_TYPE_P(RARRAY_AREF(*value, 0), T_ARRAY)){
@@ -978,8 +992,8 @@ MAKE_TO_S(Matrix_Frozen)
978
992
  VALUE v_r(rb_funcall(*value, id_r, 0, 0)), v_c(rb_funcall(*value, id_c, 0, 0));
979
993
  if(!SWIG_IsOK(SWIG_AsVal(unsigned int)(v_r, &r)) || is_lt_zero_after_asval(r)
980
994
  || !SWIG_IsOK(SWIG_AsVal(unsigned int)(v_c, &c)) || is_lt_zero_after_asval(c)){
981
- throw std::runtime_error(
982
- std::string("Unexpected length [")
995
+ throw std::invalid_argument(
996
+ std::string("Invalid length [")
983
997
  .append(inspect_str(v_r)).append(", ")
984
998
  .append(inspect_str(v_c)).append("]"));
985
999
  }
@@ -987,7 +1001,7 @@ MAKE_TO_S(Matrix_Frozen)
987
1001
  MatrixUtil::replace(res, replacer);
988
1002
  return new Matrix<T, Array2D_Type, ViewType>(res);
989
1003
  }else{
990
- throw std::runtime_error("double array [[...], ...] or Matrix is required");
1004
+ throw std::invalid_argument("double array [[...], ...] or Matrix is required");
991
1005
  }
992
1006
  }
993
1007
  #endif
@@ -1026,11 +1040,13 @@ MAKE_TO_S(Matrix_Frozen)
1026
1040
  %rename("scalar") getScalar;
1027
1041
  %rename("I") getI;
1028
1042
 
1043
+ %catches(std::out_of_range) swap_rows;
1029
1044
  void swap_rows(
1030
1045
  self_t *self_p,
1031
1046
  const unsigned int &r1, const unsigned int &r2){
1032
1047
  $self->swapRows(r1, r2);
1033
1048
  }
1049
+ %catches(std::out_of_range) swap_columns;
1034
1050
  void swap_columns(
1035
1051
  self_t *self_p,
1036
1052
  const unsigned int &c1, const unsigned int &c2){
@@ -1040,18 +1056,20 @@ MAKE_TO_S(Matrix_Frozen)
1040
1056
  template <class T2, class Array2D_Type2, class ViewType2>
1041
1057
  void replace(
1042
1058
  self_t *self_p,
1043
- const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix){
1059
+ const Matrix_Frozen<T2, Array2D_Type2, ViewType2> &matrix)
1060
+ throw(std::invalid_argument) {
1044
1061
  $self->replace(matrix);
1045
1062
  }
1046
1063
  INSTANTIATE_MATRIX_FUNC(replace, replace);
1047
1064
 
1048
- void replace(self_t *self_p, const void *replacer = NULL){
1065
+ void replace(self_t *self_p, const void *replacer = NULL)
1066
+ throw(native_exception, std::invalid_argument, std::runtime_error){
1049
1067
  if(!MatrixUtil::replace(*$self, replacer)){
1050
1068
  throw std::runtime_error("Unsupported replacement");
1051
1069
  }
1052
1070
  }
1053
1071
 
1054
- void replace(self_t *self_p, const T *serialized){
1072
+ void replace(self_t *self_p, const T *serialized) throw(std::runtime_error) {
1055
1073
  if(!MatrixUtil::replace(*$self, serialized)){
1056
1074
  throw std::runtime_error("Unsupported replacement");
1057
1075
  }
@@ -1062,6 +1080,7 @@ MAKE_TO_S(Matrix_Frozen)
1062
1080
  %bang swap_columns;
1063
1081
  %rename("replace!") replace;
1064
1082
 
1083
+ %catches(native_exception, std::invalid_argument) map_bang;
1065
1084
  void map_bang(
1066
1085
  self_t *self_p,
1067
1086
  void (*each_func)(
@@ -1129,6 +1148,7 @@ MAKE_TO_S(Matrix_Frozen)
1129
1148
  Matrix<ctype, Array2D_Dense<ctype > > &output_V {
1130
1149
  %append_output(SWIG_NewPointerObj((new $*1_ltype(*$1)), $1_descriptor, SWIG_POINTER_OWN));
1131
1150
  }
1151
+ %catches(std::logic_error, std::runtime_error) eigen;
1132
1152
  void eigen(
1133
1153
  Matrix<ctype, Array2D_Dense<ctype > > &output_V,
1134
1154
  Matrix<ctype, Array2D_Dense<ctype > > &output_D) const {
@@ -1258,7 +1278,7 @@ INSTANTIATE_MATRIX_PARTIAL(type, Array2D_Dense<type >, MatView_pt, MatView_pt);
1258
1278
  }
1259
1279
  Matrix<type, Array2D_Dense<type > > &resize(
1260
1280
  const unsigned int *r_p, const unsigned int *c_p){
1261
- unsigned int r(r_p ? *r_p : $self->rows()), c(c_p ? *c_p : self->columns());
1281
+ unsigned int r(r_p ? *r_p : $self->rows()), c(c_p ? *c_p : $self->columns());
1262
1282
  Matrix<type, Array2D_Dense<type > > mat_new(r, c);
1263
1283
  unsigned int r_min(r), c_min(c);
1264
1284
  if(r_min > $self->rows()){r_min = $self->rows();}
@@ -918,7 +918,7 @@ __RINEX_CLK_TEXT__
918
918
  expect(solver.options[:skip_exclusion]).to eq(true)
919
919
  expect(solver.correction[:gps_ionospheric]).to include(:klobuchar)
920
920
  expect(solver.correction[:gps_tropospheric]).to include(:hopfield)
921
- expect{solver.correction = nil}.to raise_error(RuntimeError)
921
+ expect{solver.correction = nil}.to raise_error(ArgumentError)
922
922
  expect{solver.correction = {
923
923
  :gps_ionospheric => [proc{|t, usr_pos, sat_pos|
924
924
  expect(t).to be_a_kind_of(GPS::Time)