1 /* { dg-do compile } */
3 template < typename > class basic_stringstream;
13 class ostream:ios_base {};
14 class istream:virtual ios_base {};
16 template < typename > struct basic_iostream:public istream, ostream {
19 extern template class basic_iostream < char >;
21 template < typename > struct basic_stringstream:public basic_iostream < char > {
22 basic_string _M_stringbuf;
23 ~basic_stringstream () {}
25 extern template class basic_stringstream < char >;
27 template < typename > struct AnyMatrixBase;
28 template < typename, int _Rows, int _Cols, int = _Rows, int = _Cols > class Matrix;
29 template < typename > class CwiseNullaryOp;
31 template < typename Derived > struct MatrixBase:public AnyMatrixBase < Derived > {
32 typedef CwiseNullaryOp < Derived > ConstantReturnType;
33 ConstantReturnType Constant ();
34 template < typename > Derived cast ();
35 static CwiseNullaryOp < Derived > Random (int);
38 template < typename Derived > struct AnyMatrixBase {
40 Derived & derived () const {}
43 template < typename, int > struct ei_matrix_storage {};
45 template < typename _Scalar, int, int, int _MaxRows, int _MaxCols > struct Matrix:MatrixBase < Matrix < _Scalar, _MaxRows, _MaxCols > > {
46 typedef MatrixBase < Matrix > Base;
47 ei_matrix_storage < int, _MaxCols > m_storage;
48 Matrix operator= (const Matrix other) {
49 _resize_to_match (other);
50 lazyAssign (other.derived ());
52 template < typename OtherDerived > Matrix lazyAssign (MatrixBase < OtherDerived > other) {
53 _resize_to_match (other);
54 return Base (other.derived ());
57 template < typename OtherDerived > Matrix (const MatrixBase < OtherDerived > &other) {
60 template < typename OtherDerived > void _resize_to_match (const MatrixBase < OtherDerived > &) {
65 template < typename MatrixType > class CwiseNullaryOp:
66 public MatrixBase < CwiseNullaryOp < MatrixType > > {};
72 basic_stringstream<char> sstr;
77 template < typename > struct AutoDiffScalar;
78 template < typename Functor > struct AutoDiffJacobian:Functor {
79 AutoDiffJacobian (Functor);
80 typedef typename Functor::InputType InputType;
81 typedef typename Functor::ValueType ValueType;
82 typedef Matrix < int, Functor::InputsAtCompileTime, 1 > DerivativeType;
83 typedef AutoDiffScalar < DerivativeType > ActiveScalar;
84 typedef Matrix < ActiveScalar, Functor::InputsAtCompileTime, 1 > ActiveInput;
85 void operator () (InputType x, ValueType *) {
86 ActiveInput ax = x.template cast < ActiveScalar > ();
90 template < int NX, int NY > struct TestFunc1 {
92 InputsAtCompileTime = NX
94 typedef Matrix < float, NX, 1 > InputType;
95 typedef Matrix < float, NY, 1 > ValueType;
96 typedef Matrix < float, NY, NX > JacobianType;
100 template < typename Func > void forward_jacobian (Func f) {
101 typename Func::InputType x = Func::InputType::Random (f.inputs ());
102 typename Func::ValueType y;
103 typename Func::JacobianType jref = jref.Constant ();
104 AutoDiffJacobian < Func > autoj (f);
108 void test_autodiff_scalar ()
110 forward_jacobian (TestFunc1 < 2, 2 > ());
111 forward_jacobian (TestFunc1 < 3, 2 > ());