Stan  1.1
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
error_handling.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__ERROR_HANDLING_HPP__
2 #define __STAN__MATH__ERROR_HANDLING_HPP__
3 
4 #include <algorithm>
5 #include <cstddef>
6 #include <limits>
7 #include <utility>
8 #include <iostream>
9 
10 #include <boost/math/policies/policy.hpp>
11 #include <boost/type_traits/is_unsigned.hpp>
12 
13 #include <stan/meta/traits.hpp>
15 
16 namespace stan {
17 
18  namespace math {
19 
24  const double CONSTRAINT_TOLERANCE = 1E-8;
25 
26 
30  typedef boost::math::policies::policy<> default_policy;
31 
32  namespace {
33 
34  // local output stream for pairs
35  template <typename T1, typename T2>
36  std::ostream& operator<<(std::ostream& o,
37  std::pair<T1,T2> xs) {
38  o << '(' << xs.first << ", " << xs.second << ')';
39  return o;
40  }
41 
42  template <typename T_y,
43  typename T_result,
44  typename T_msg2,
45  class Policy>
46  inline bool dom_err(const char* function,
47  const T_y& y,
48  const char* name,
49  const char* error_msg,
50  T_msg2 error_msg2,
51  T_result* result,
52  const Policy&) {
54  std::ostringstream msg_o;
55  msg_o << name << error_msg << error_msg2;
56  T_result tmp = raise_domain_error<T_result,T_y>(function,
57  msg_o.str().c_str(),
58  y,
59  Policy());
60  if (result != 0)
61  *result = tmp;
62  return false;
63  }
64 
65  template <typename T_y,
66  typename T_result,
67  typename T_msg2,
68  class Policy>
69  inline bool dom_err_vec(size_t i,
70  const char* function,
71  const T_y& y,
72  const char* name,
73  const char* error_msg,
74  T_msg2 error_msg2,
75  T_result* result,
76  const Policy&) {
78  std::ostringstream msg_o;
79  msg_o << name << "[" << i << "] " << error_msg << error_msg2;
80  T_result tmp
81  = raise_domain_error<T_result,
82  typename T_y::value_type>(function,
83  msg_o.str().c_str(),
84  stan::get(y,i),
85  Policy());
86  if (result != 0)
87  *result = tmp;
88  return false;
89  }
90  } // end anon namespace
91 
92  namespace {
93  template <typename T_y,
94  typename T_result,
95  class Policy,
96  bool is_vec>
97  struct not_nan {
98  static bool check(const char* function,
99  const T_y& y,
100  const char* name,
101  T_result* result,
102  const Policy&) {
103  if ((boost::math::isnan)(y))
104  return dom_err(function,y,name,
105  " is %1%, but must not be nan!","",
106  result,Policy());
107  return true;
108  }
109  };
110 
111  template <typename T_y,
112  typename T_result,
113  class Policy>
114  struct not_nan<T_y, T_result, Policy, true> {
115  static bool check(const char* function,
116  const T_y& y,
117  const char* name,
118  T_result* result,
119  const Policy&) {
120  // using stan::length;
121  for (size_t n = 0; n < stan::length(y); n++) {
122  if ((boost::math::isnan)(stan::get(y,n)))
123  return dom_err_vec(n,function,y,name,
124  " is %1%, but must not be nan!","",
125  result,Policy());
126  }
127  return true;
128  }
129  };
130  }
131 
143  template <typename T_y,
144  typename T_result,
145  class Policy>
146  inline bool check_not_nan(const char* function,
147  const T_y& y,
148  const char* name,
149  T_result* result,
150  const Policy&) {
151  return not_nan<T_y,T_result,Policy,
153  ::check(function, y, name, result, Policy());
154  }
155 
167  template <typename T_y,
168  typename T_result>
169  inline bool check_not_nan(const char* function,
170  const T_y& y,
171  const char* name,
172  T_result* result = 0) {
173  return check_not_nan(function,y,name,result,default_policy());
174  }
175  // need this sig to infer types for result from type of y
176  template <typename T>
177  inline bool check_not_nan(const char* function,
178  const T& y,
179  const char* name) {
180  return check_not_nan<T, typename scalar_type<T>::type *>
181  (function,y,name,0,default_policy());
182  }
183 
184 
185  namespace {
186  template <typename T_y,
187  typename T_result,
188  class Policy,
189  bool is_vec>
190  struct finite {
191  static bool check(const char* function,
192  const T_y& y,
193  const char* name,
194  T_result* result,
195  const Policy&) {
196  if (!(boost::math::isfinite)(y))
197  return dom_err(function,y,name,
198  " is %1%, but must be finite!","",
199  result,Policy());
200  return true;
201  }
202  };
203 
204  template <typename T_y,
205  typename T_result,
206  class Policy>
207  struct finite<T_y, T_result, Policy, true> {
208  static bool check(const char* function,
209  const T_y& y,
210  const char* name,
211  T_result* result,
212  const Policy&) {
213  using stan::length;
214  for (size_t n = 0; n < length(y); n++) {
215  if (!(boost::math::isfinite)(stan::get(y,n)))
216  return dom_err_vec(n,function,y,name,
217  " is %1%, but must be finite!","",
218  result,Policy());
219  }
220  return true;
221  }
222  };
223  }
227  template <typename T_y, typename T_result, class Policy>
228  inline bool check_finite(const char* function,
229  const T_y& y,
230  const char* name,
231  T_result* result,
232  const Policy&) {
233  return finite<T_y,T_result,Policy,
235  ::check(function, y, name, result, Policy());
236  }
237 
238  template <typename T_y, typename T_result>
239  inline bool check_finite(const char* function,
240  const T_y& y,
241  const char* name,
242  T_result* result) {
243  return check_finite(function,y,name,result,default_policy());
244  }
245 
246  template <typename T>
247  inline bool check_finite(const char* function,
248  const T& y,
249  const char* name) {
250  return check_finite<T,typename scalar_type<T>::type *>
251  (function,y,name,0,default_policy());
252  }
253 
254  namespace {
255  template <typename T_y,
256  typename T_low,
257  typename T_result,
258  class Policy,
259  bool is_vec>
260  struct greater {
261  static bool check(const char* function,
262  const T_y& y,
263  const T_low& low,
264  const char* name,
265  T_result* result,
266  const Policy&) {
267  using stan::length;
268  VectorView<const T_low> low_vec(low);
269  for (size_t n = 0; n < length(low); n++) {
270  if (!(y > low_vec[n]))
271  return dom_err(function,y,name,
272  " is %1%, but must be greater than ",
273  low_vec[n],result,Policy());
274  }
275  return true;
276  }
277  };
278 
279  template <typename T_y,
280  typename T_low,
281  typename T_result,
282  class Policy>
283  struct greater<T_y, T_low, T_result, Policy, true> {
284  static bool check(const char* function,
285  const T_y& y,
286  const T_low& low,
287  const char* name,
288  T_result* result,
289  const Policy&) {
290  using stan::length;
291  VectorView<const T_low> low_vec(low);
292  for (size_t n = 0; n < length(y); n++) {
293  if (!(stan::get(y,n) > low_vec[n])) {
294  return dom_err_vec(n,function,y,name,
295  " is %1%, but must be greater than ",
296  low_vec[n],result,Policy());
297  }
298  }
299  return true;
300  }
301  };
302  }
303  template <typename T_y, typename T_low, typename T_result, class Policy>
304  inline bool check_greater(const char* function,
305  const T_y& y,
306  const T_low& low,
307  const char* name,
308  T_result* result,
309  const Policy&) {
310  return greater<T_y,T_low,T_result,Policy,
311  is_vector_like<T_y>::value>::check(function,y,low,name,result,Policy());
312  }
313  template <typename T_y, typename T_low, typename T_result>
314  inline bool check_greater(const char* function,
315  const T_y& y,
316  const T_low& low,
317  const char* name,
318  T_result* result) {
319  return check_greater(function,y,low,name,result,default_policy());
320  }
321  template <typename T_y, typename T_low>
322  inline bool check_greater(const char* function,
323  const T_y& y,
324  const T_low& low,
325  const char* name) {
326  return check_greater<T_y,T_low,typename scalar_type<T_y>::type *>
327  (function,y,low,name,0,default_policy());
328  }
329 
330  namespace {
331  template <typename T_y,
332  typename T_low,
333  typename T_result,
334  class Policy,
335  bool is_vec>
336  struct greater_or_equal {
337  static bool check(const char* function,
338  const T_y& y,
339  const T_low& low,
340  const char* name,
341  T_result* result,
342  const Policy&) {
343  using stan::length;
344  VectorView<const T_low> low_vec(low);
345  for (size_t n = 0; n < length(low); n++) {
346  if (!(y >= low_vec[n]))
347  return dom_err(function,y,name,
348  " is %1%, but must be greater than ",
349  low_vec[n],result,Policy());
350  }
351  return true;
352  }
353  };
354 
355  template <typename T_y,
356  typename T_low,
357  typename T_result,
358  class Policy>
359  struct greater_or_equal<T_y, T_low, T_result, Policy, true> {
360  static bool check(const char* function,
361  const T_y& y,
362  const T_low& low,
363  const char* name,
364  T_result* result,
365  const Policy&) {
366  using stan::length;
367  using stan::get;
368  VectorView<const T_low> low_vec(low);
369  for (size_t n = 0; n < length(y); n++) {
370  if (!(get(y,n) >= low_vec[n]))
371  return dom_err_vec(n,function,y,name,
372  " is %1%, but must be greater than or equal to ",
373  low_vec[n],result,Policy());
374  }
375  return true;
376  }
377  };
378  }
379  template <typename T_y, typename T_low, typename T_result, class Policy>
380  inline bool check_greater_or_equal(const char* function,
381  const T_y& y,
382  const T_low& low,
383  const char* name,
384  T_result* result,
385  const Policy&) {
386  return greater_or_equal<T_y,T_low,T_result,Policy,is_vector_like<T_y>::value>::check(function,y,low,name,result,Policy());
387  }
388  template <typename T_y, typename T_low, typename T_result>
389  inline bool check_greater_or_equal(const char* function,
390  const T_y& y,
391  const T_low& low,
392  const char* name,
393  T_result* result) {
394  return check_greater_or_equal(function,y,low,name,result,
395  default_policy());
396  }
397  template <typename T_y, typename T_low>
398  inline bool check_greater_or_equal(const char* function,
399  const T_y& y,
400  const T_low& low,
401  const char* name) {
402  return check_greater_or_equal<T_y,T_low,typename scalar_type<T_y>::type *>
403  (function,y,low,name,0,default_policy());
404  }
405 
406  namespace {
407  template <typename T_y,
408  typename T_high,
409  typename T_result,
410  class Policy,
411  bool is_vec>
412  struct less {
413  static bool check(const char* function,
414  const T_y& y,
415  const T_high& high,
416  const char* name,
417  T_result* result,
418  const Policy&) {
419  using stan::length;
420  VectorView<const T_high> high_vec(high);
421  for (size_t n = 0; n < length(high); n++) {
422  if (!(y < high_vec[n]))
423  return dom_err(function,y,name,
424  " is %1%, but must be less than ",
425  high_vec[n],result,Policy());
426  }
427  return true;
428  }
429  };
430 
431  template <typename T_y,
432  typename T_high,
433  typename T_result,
434  class Policy>
435  struct less<T_y, T_high, T_result, Policy, true> {
436  static bool check(const char* function,
437  const T_y& y,
438  const T_high& high,
439  const char* name,
440  T_result* result,
441  const Policy&) {
442  using stan::length;
443  VectorView<const T_high> high_vec(high);
444  for (size_t n = 0; n < length(y); n++) {
445  if (!(stan::get(y,n) < high_vec[n]))
446  return dom_err_vec(n,function,y,name,
447  " is %1%, but must be less than ",
448  high_vec[n],result,Policy());
449  }
450  return true;
451  }
452  };
453  }
454  template <typename T_y, typename T_high, typename T_result, class Policy>
455  inline bool check_less(const char* function,
456  const T_y& y,
457  const T_high& high,
458  const char* name,
459  T_result* result,
460  const Policy&) {
461  return less<T_y,T_high,T_result,Policy,is_vector_like<T_y>::value>
462  ::check(function,y,high,name,result,Policy());
463  }
464  template <typename T_y, typename T_high, typename T_result>
465  inline bool check_less(const char* function,
466  const T_y& y,
467  const T_high& high,
468  const char* name,
469  T_result* result) {
470  return check_less(function,y,high,name,result,default_policy());
471  }
472  template <typename T_y, typename T_high>
473  inline bool check_less(const char* function,
474  const T_y& y,
475  const T_high& high,
476  const char* name) {
477  return check_less<T_y,T_high,typename scalar_type<T_y>::type *>
478  (function,y,high,name,0,default_policy());
479  }
480 
481  namespace {
482  template <typename T_y,
483  typename T_high,
484  typename T_result,
485  class Policy,
486  bool is_vec>
487  struct less_or_equal {
488  static bool check(const char* function,
489  const T_y& y,
490  const T_high& high,
491  const char* name,
492  T_result* result,
493  const Policy&) {
494  using stan::length;
495  VectorView<const T_high> high_vec(high);
496  for (size_t n = 0; n < length(high); n++) {
497  if (!(y <= high_vec[n]))
498  return dom_err(function,y,name,
499  " is %1%, but must be less than or equal to ",
500  high_vec[n],result,Policy());
501  }
502  return true;
503  }
504  };
505 
506  template <typename T_y,
507  typename T_high,
508  typename T_result,
509  class Policy>
510  struct less_or_equal<T_y, T_high, T_result, Policy, true> {
511  static bool check(const char* function,
512  const T_y& y,
513  const T_high& high,
514  const char* name,
515  T_result* result,
516  const Policy&) {
517  using stan::length;
518  VectorView<const T_high> high_vec(high);
519  for (size_t n = 0; n < length(y); n++) {
520  if (!(stan::get(y,n) <= high_vec[n]))
521  return dom_err_vec(n,function,y,name,
522  " is %1%, but must be less than or equal to ",
523  high_vec[n],result,Policy());
524  }
525  return true;
526  }
527  };
528  }
529  template <typename T_y, typename T_high, typename T_result, class Policy>
530  inline bool check_less_or_equal(const char* function,
531  const T_y& y,
532  const T_high& high,
533  const char* name,
534  T_result* result,
535  const Policy&) {
536  return less_or_equal<T_y,T_high,T_result,Policy,
538  ::check(function,y,high,name,result,Policy());
539  }
540  template <typename T_y, typename T_high, typename T_result>
541  inline bool check_less_or_equal(const char* function,
542  const T_y& y,
543  const T_high& high,
544  const char* name,
545  T_result* result) {
546  return check_less_or_equal(function,y,high,name,result,default_policy());
547  }
548  template <typename T_y, typename T_high>
549  inline bool check_less_or_equal(const char* function,
550  const T_y& y,
551  const T_high& high,
552  const char* name) {
553  return check_less_or_equal<T_y,T_high,typename scalar_type<T_y>::type *>
554  (function,y,high,name,0,default_policy());
555  }
556 
557  namespace {
558  template <typename T_y,
559  typename T_low,
560  typename T_high,
561  typename T_result,
562  class Policy,
563  bool is_vec>
564  struct bounded {
565  static bool check(const char* function,
566  const T_y& y,
567  const T_low& low,
568  const T_high& high,
569  const char* name,
570  T_result* result,
571  const Policy&) {
572  using stan::length;
573  using stan::max_size;
574  VectorView<const T_low> low_vec(low);
575  VectorView<const T_high> high_vec(high);
576  for (size_t n = 0; n < max_size(low, high); n++) {
577  if (!(low_vec[n] <= y && y <= high_vec[n]))
578  return dom_err(function,y,name," is %1%, but must be between ",
579  std::pair<typename scalar_type<T_low>::type,
580  typename scalar_type<T_high>::type>(low_vec[n],
581  high_vec[n]),
582  result,Policy());
583  }
584  return true;
585  }
586  };
587 
588  template <typename T_y,
589  typename T_low,
590  typename T_high,
591  typename T_result,
592  class Policy>
593  struct bounded<T_y, T_low, T_high, T_result, Policy, true> {
594  static bool check(const char* function,
595  const T_y& y,
596  const T_low& low,
597  const T_high& high,
598  const char* name,
599  T_result* result,
600  const Policy&) {
601  using stan::length;
602  using stan::get;
603  VectorView<const T_low> low_vec(low);
604  VectorView<const T_high> high_vec(high);
605  for (size_t n = 0; n < length(y); n++) {
606  if (!(low_vec[n] <= get(y,n) && get(y,n) <= high_vec[n]))
607  return dom_err_vec(n,function,y,name,
608  " is %1%, but must be between ",
609  std::pair<typename scalar_type<T_low>::type,
610  typename scalar_type<T_high>::type>(low_vec[n],
611  high_vec[n]),
612  result,Policy());
613  }
614  return true;
615  }
616  };
617  }
618  template <typename T_y, typename T_low, typename T_high, typename T_result, class Policy>
619  inline bool check_bounded(const char* function,
620  const T_y& y,
621  const T_low& low,
622  const T_high& high,
623  const char* name,
624  T_result* result,
625  const Policy&) {
626  return bounded<T_y,T_low,T_high,T_result,Policy,
628  ::check(function,y,low,high,name,result,Policy());
629  }
630  template <typename T_y, typename T_low, typename T_high, typename T_result>
631  inline bool check_bounded(const char* function,
632  const T_y& y,
633  const T_low& low,
634  const T_high& high,
635  const char* name,
636  T_result* result) {
637  return check_bounded(function,y,low,high,name,result,default_policy());
638  }
639  template <typename T_y, typename T_low, typename T_high>
640  inline bool check_bounded(const char* function,
641  const T_y& y,
642  const T_low& low,
643  const T_high& high,
644  const char* name) {
645  return check_bounded<T_y,T_low,T_high,typename scalar_type<T_y>::type *>
646  (function,y,low,high,name,0,default_policy());
647  }
648 
649  namespace {
650  template <typename T_y,
651  typename T_result,
652  class Policy,
653  bool is_vec>
654  struct nonnegative {
655  static bool check(const char* function,
656  const T_y& y,
657  const char* name,
658  T_result* result,
659  const Policy&) {
660  // have to use not is_unsigned. is_signed will be false
661  // floating point types that have no unsigned versions.
662  if (!boost::is_unsigned<T_y>::value && !(y >= 0))
663  return dom_err(function,y,name,
664  " is %1%, but must be >= 0!","",
665  result,Policy());
666  return true;
667  }
668  };
669 
670  template <typename T_y,
671  typename T_result,
672  class Policy>
673  struct nonnegative<T_y, T_result, Policy, true> {
674  static bool check(const char* function,
675  const T_y& y,
676  const char* name,
677  T_result* result,
678  const Policy&) {
679  using stan::length;
680  for (size_t n = 0; n < length(y); n++) {
681  if (!boost::is_unsigned<typename T_y::value_type>::value
682  && !(stan::get(y,n) >= 0))
683  return dom_err_vec(n,function,y,name,
684  " is %1%, but must be >= 0!","",
685  result,Policy());
686  }
687  return true;
688  }
689  };
690  }
691  template <typename T_y, typename T_result, class Policy>
692  inline bool check_nonnegative(const char* function,
693  const T_y& y,
694  const char* name,
695  T_result* result,
696  const Policy&) {
697  return nonnegative<T_y,T_result,Policy,
699  ::check(function, y, name, result, Policy());
700  }
701  template <typename T_y, typename T_result>
702  inline bool check_nonnegative(const char* function,
703  const T_y& y,
704  const char* name,
705  T_result* result) {
706  return check_nonnegative(function,y,name,result,default_policy());
707  }
708  template <typename T_y>
709  inline bool check_nonnegative(const char* function,
710  const T_y& y,
711  const char* name) {
712  return check_nonnegative<T_y,typename scalar_type<T_y>::type *>
713  (function,y,name,0,default_policy());
714  }
715 
716 
717 
718  namespace {
719  template <typename T_y,
720  typename T_result,
721  class Policy,
722  bool is_vec>
723  struct positive {
724  static bool check(const char* function,
725  const T_y& y,
726  const char* name,
727  T_result* result,
728  const Policy&) {
729  // have to use not is_unsigned. is_signed will be false
730  // floating point types that have no unsigned versions.
731  if (!boost::is_unsigned<T_y>::value && !(y > 0))
732  return dom_err(function,y,name,
733  " is %1%, but must be > 0!","",
734  result,Policy());
735  return true;
736  }
737  };
738 
739  template <typename T_y,
740  typename T_result,
741  class Policy>
742  struct positive<T_y, T_result, Policy, true> {
743  static bool check(const char* function,
744  const T_y& y,
745  const char* name,
746  T_result* result,
747  const Policy&) {
748  using stan::length;
749  for (size_t n = 0; n < length(y); n++) {
750  if (!boost::is_unsigned<typename T_y::value_type>::value
751  && !(stan::get(y,n) > 0))
752  return dom_err_vec(n,function,y,name,
753  " is %1%, but must be > 0!","",
754  result,Policy());
755  }
756  return true;
757  }
758  };
759  }
760  template <typename T_y, typename T_result, class Policy>
761  inline bool check_positive(const char* function,
762  const T_y& y,
763  const char* name,
764  T_result* result,
765  const Policy&) {
766  return positive<T_y,T_result,Policy,
768  ::check(function, y, name, result, Policy());
769  }
770  template <typename T_x, typename T_result>
771  inline bool check_positive(const char* function,
772  const T_x& x,
773  const char* name,
774  T_result* result) {
775  return check_positive(function,x,name,result,default_policy());
776  }
777  template <typename T>
778  inline bool check_positive(const char* function,
779  const T& x,
780  const char* name) {
781  return check_positive<T,typename scalar_type<T>::type *>
782  (function,x,name,0,default_policy());
783  }
784 
785  template <typename T, typename T_result, class Policy>
786  inline bool check_consistent_size(size_t max_size,
787  const char* function,
788  const T& x,
789  const char* name,
790  T_result* result,
791  const Policy&) {
792  size_t x_size = stan::size_of(x);
793  if (is_vector<T>::value && x_size == max_size)
794  return true;
795  if (!is_vector<T>::value && x_size == 1)
796  return true;
797  return dom_err(
798  function,x_size,name,
799  " (max size) is %1%, but must be consistent, 1 or max=",max_size,
800  result,Policy());
801  }
802 
803  template <typename T1, typename T2, typename T_result,
804  class Policy>
805  inline bool check_consistent_sizes(const char* function,
806  const T1& x1,
807  const T2& x2,
808  const char* name1,
809  const char* name2,
810  T_result* result,
811  const Policy&) {
812  size_t max_size = std::max(size_of(x1),
813  size_of(x2));
814  return check_consistent_size(max_size,function,x1,name1,result,Policy())
815  && check_consistent_size(max_size,function,x2,name2,result,Policy());
816  }
817  template <typename T1, typename T2, typename T_result>
818  inline bool check_consistent_sizes(const char* function,
819  const T1& x1,
820  const T2& x2,
821  const char* name1,
822  const char* name2,
823  T_result* result) {
824  return check_consistent_sizes(function,x1,x2,name1,name2,
825  result,default_policy());
826  }
827 
828  template <typename T1, typename T2, typename T3, typename T_result,
829  class Policy>
830  inline bool check_consistent_sizes(const char* function,
831  const T1& x1,
832  const T2& x2,
833  const T3& x3,
834  const char* name1,
835  const char* name2,
836  const char* name3,
837  T_result* result,
838  const Policy&) {
839  size_t max_size = std::max(size_of(x1),
840  std::max(size_of(x2),size_of(x3)));
841  return check_consistent_size(max_size,function,x1,name1,result,Policy())
842  && check_consistent_size(max_size,function,x2,name2,result,Policy())
843  && check_consistent_size(max_size,function,x3,name3,result,Policy());
844  }
845  template <typename T1, typename T2, typename T3, typename T_result>
846  inline bool check_consistent_sizes(const char* function,
847  const T1& x1,
848  const T2& x2,
849  const T3& x3,
850  const char* name1,
851  const char* name2,
852  const char* name3,
853  T_result* result) {
854  return check_consistent_sizes(function,x1,x2,x3,name1,name2,name3,
855  result,default_policy());
856  }
857  template <typename T1, typename T2, typename T3, typename T4,
858  typename T_result,
859  class Policy>
860  inline bool check_consistent_sizes(const char* function,
861  const T1& x1,
862  const T2& x2,
863  const T3& x3,
864  const T4& x4,
865  const char* name1,
866  const char* name2,
867  const char* name3,
868  const char* name4,
869  T_result* result,
870  const Policy&) {
871  size_t max_size = std::max(size_of(x1),
872  std::max(size_of(x2),
873  std::max(size_of(x3), size_of(x4))));
874  return check_consistent_size(max_size,function,x1,name1,result,Policy())
875  && check_consistent_size(max_size,function,x2,name2,result,Policy())
876  && check_consistent_size(max_size,function,x3,name3,result,Policy())
877  && check_consistent_size(max_size,function,x4,name4,result,Policy());
878  }
879  template <typename T1, typename T2, typename T3, typename T4, typename T_result>
880  inline bool check_consistent_sizes(const char* function,
881  const T1& x1,
882  const T2& x2,
883  const T3& x3,
884  const T4& x4,
885  const char* name1,
886  const char* name2,
887  const char* name3,
888  const char* name4,
889  T_result* result) {
890  return check_consistent_sizes(function,x1,x2,x3,x4,
891  name1,name2,name3,name4,
892  result,default_policy());
893  }
894 
895 
896  }
897 }
898 
899 #endif
900 

     [ Stan Home Page ] © 2011–2013, Stan Development Team.