Pulled the latest updates from the eigen trunk.

This commit is contained in:
Benoit Steiner 2014-04-01 22:07:05 -07:00
commit aecc78325a
15 changed files with 137 additions and 139 deletions

View File

@ -91,4 +91,5 @@ void printBenchStyle(std::ofstream& out)
</xsl:stylesheet>\n\n"; </xsl:stylesheet>\n\n";
} }
#endif #endif

View File

@ -106,13 +106,13 @@ matrix(T* data, int rows, int cols, int stride)
} }
template<typename T> template<typename T>
Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> > vector(T* data, int size, int incr) Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> > make_vector(T* data, int size, int incr)
{ {
return Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> >(data, size, InnerStride<Dynamic>(incr)); return Map<Matrix<T,Dynamic,1>, 0, InnerStride<Dynamic> >(data, size, InnerStride<Dynamic>(incr));
} }
template<typename T> template<typename T>
Map<Matrix<T,Dynamic,1> > vector(T* data, int size) Map<Matrix<T,Dynamic,1> > make_vector(T* data, int size)
{ {
return Map<Matrix<T,Dynamic,1> >(data, size); return Map<Matrix<T,Dynamic,1> >(data, size);
} }
@ -124,8 +124,8 @@ T* get_compact_vector(T* x, int n, int incx)
return x; return x;
T* ret = new Scalar[n]; T* ret = new Scalar[n];
if(incx<0) vector(ret,n) = vector(x,n,-incx).reverse(); if(incx<0) make_vector(ret,n) = make_vector(x,n,-incx).reverse();
else vector(ret,n) = vector(x,n, incx); else make_vector(ret,n) = make_vector(x,n, incx);
return ret; return ret;
} }
@ -135,8 +135,8 @@ T* copy_back(T* x_cpy, T* x, int n, int incx)
if(x_cpy==x) if(x_cpy==x)
return 0; return 0;
if(incx<0) vector(x,n,-incx).reverse() = vector(x_cpy,n); if(incx<0) make_vector(x,n,-incx).reverse() = make_vector(x_cpy,n);
else vector(x,n, incx) = vector(x_cpy,n); else make_vector(x,n, incx) = make_vector(x_cpy,n);
return x_cpy; return x_cpy;
} }

View File

@ -23,11 +23,10 @@ double BLASFUNC(dsdot)(int* n, float* x, int* incx, float* y, int* incy)
{ {
if(*n<=0) return 0; if(*n<=0) return 0;
if(*incx==1 && *incy==1) return (vector(x,*n).cast<double>().cwiseProduct(vector(y,*n).cast<double>())).sum(); if(*incx==1 && *incy==1) return (make_vector(x,*n).cast<double>().cwiseProduct(make_vector(y,*n).cast<double>())).sum();
else if(*incx>0 && *incy>0) return (vector(x,*n,*incx).cast<double>().cwiseProduct(vector(y,*n,*incy).cast<double>())).sum(); else if(*incx>0 && *incy>0) return (make_vector(x,*n,*incx).cast<double>().cwiseProduct(make_vector(y,*n,*incy).cast<double>())).sum();
else if(*incx<0 && *incy>0) return (vector(x,*n,-*incx).reverse().cast<double>().cwiseProduct(vector(y,*n,*incy).cast<double>())).sum(); else if(*incx<0 && *incy>0) return (make_vector(x,*n,-*incx).reverse().cast<double>().cwiseProduct(make_vector(y,*n,*incy).cast<double>())).sum();
else if(*incx>0 && *incy<0) return (vector(x,*n,*incx).cast<double>().cwiseProduct(vector(y,*n,-*incy).reverse().cast<double>())).sum(); else if(*incx>0 && *incy<0) return (make_vector(x,*n,*incx).cast<double>().cwiseProduct(make_vector(y,*n,-*incy).reverse().cast<double>())).sum();
else if(*incx<0 && *incy<0) return (vector(x,*n,-*incx).reverse().cast<double>().cwiseProduct(vector(y,*n,-*incy).reverse().cast<double>())).sum(); else if(*incx<0 && *incy<0) return (make_vector(x,*n,-*incx).reverse().cast<double>().cwiseProduct(make_vector(y,*n,-*incy).reverse().cast<double>())).sum();
else return 0; else return 0;
} }

View File

@ -32,13 +32,14 @@ RealScalar EIGEN_CAT(EIGEN_CAT(REAL_SCALAR_SUFFIX,SCALAR_SUFFIX),asum_)(int *n,
if(*n<=0) return 0; if(*n<=0) return 0;
if(*incx==1) return vector(x,*n).unaryExpr<scalar_norm1_op>().sum(); if(*incx==1) return make_vector(x,*n).unaryExpr<scalar_norm1_op>().sum();
else return vector(x,*n,std::abs(*incx)).unaryExpr<scalar_norm1_op>().sum(); else return make_vector(x,*n,std::abs(*incx)).unaryExpr<scalar_norm1_op>().sum();
} }
// computes a dot product of a conjugated vector with another vector. // computes a dot product of a conjugated vector with another vector.
int EIGEN_BLAS_FUNC(dotcw)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar* pres) int EIGEN_BLAS_FUNC(dotcw)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar* pres)
{ {
// std::cerr << "_dotc " << *n << " " << *incx << " " << *incy << "\n";
Scalar* res = reinterpret_cast<Scalar*>(pres); Scalar* res = reinterpret_cast<Scalar*>(pres);
if(*n<=0) if(*n<=0)
@ -50,11 +51,11 @@ int EIGEN_BLAS_FUNC(dotcw)(int *n, RealScalar *px, int *incx, RealScalar *py, in
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py); Scalar* y = reinterpret_cast<Scalar*>(py);
if(*incx==1 && *incy==1) *res = (vector(x,*n).dot(vector(y,*n))); if(*incx==1 && *incy==1) *res = (make_vector(x,*n).dot(make_vector(y,*n)));
else if(*incx>0 && *incy>0) *res = (vector(x,*n,*incx).dot(vector(y,*n,*incy))); else if(*incx>0 && *incy>0) *res = (make_vector(x,*n,*incx).dot(make_vector(y,*n,*incy)));
else if(*incx<0 && *incy>0) *res = (vector(x,*n,-*incx).reverse().dot(vector(y,*n,*incy))); else if(*incx<0 && *incy>0) *res = (make_vector(x,*n,-*incx).reverse().dot(make_vector(y,*n,*incy)));
else if(*incx>0 && *incy<0) *res = (vector(x,*n,*incx).dot(vector(y,*n,-*incy).reverse())); else if(*incx>0 && *incy<0) *res = (make_vector(x,*n,*incx).dot(make_vector(y,*n,-*incy).reverse()));
else if(*incx<0 && *incy<0) *res = (vector(x,*n,-*incx).reverse().dot(vector(y,*n,-*incy).reverse())); else if(*incx<0 && *incy<0) *res = (make_vector(x,*n,-*incx).reverse().dot(make_vector(y,*n,-*incy).reverse()));
return 0; return 0;
} }
@ -72,11 +73,11 @@ int EIGEN_BLAS_FUNC(dotuw)(int *n, RealScalar *px, int *incx, RealScalar *py, in
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py); Scalar* y = reinterpret_cast<Scalar*>(py);
if(*incx==1 && *incy==1) *res = (vector(x,*n).cwiseProduct(vector(y,*n))).sum(); if(*incx==1 && *incy==1) *res = (make_vector(x,*n).cwiseProduct(make_vector(y,*n))).sum();
else if(*incx>0 && *incy>0) *res = (vector(x,*n,*incx).cwiseProduct(vector(y,*n,*incy))).sum(); else if(*incx>0 && *incy>0) *res = (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,*incy))).sum();
else if(*incx<0 && *incy>0) *res = (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,*incy))).sum(); else if(*incx<0 && *incy>0) *res = (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,*incy))).sum();
else if(*incx>0 && *incy<0) *res = (vector(x,*n,*incx).cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); else if(*incx>0 && *incy<0) *res = (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
else if(*incx<0 && *incy<0) *res = (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); else if(*incx<0 && *incy<0) *res = (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
return 0; return 0;
} }
@ -88,9 +89,9 @@ RealScalar EIGEN_CAT(EIGEN_CAT(REAL_SCALAR_SUFFIX,SCALAR_SUFFIX),nrm2_)(int *n,
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
if(*incx==1) if(*incx==1)
return vector(x,*n).stableNorm(); return make_vector(x,*n).stableNorm();
return vector(x,*n,*incx).stableNorm(); return make_vector(x,*n,*incx).stableNorm();
} }
int EIGEN_CAT(EIGEN_CAT(SCALAR_SUFFIX,REAL_SCALAR_SUFFIX),rot_)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps) int EIGEN_CAT(EIGEN_CAT(SCALAR_SUFFIX,REAL_SCALAR_SUFFIX),rot_)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
@ -102,8 +103,8 @@ int EIGEN_CAT(EIGEN_CAT(SCALAR_SUFFIX,REAL_SCALAR_SUFFIX),rot_)(int *n, RealScal
RealScalar c = *pc; RealScalar c = *pc;
RealScalar s = *ps; RealScalar s = *ps;
StridedVectorType vx(vector(x,*n,std::abs(*incx))); StridedVectorType vx(make_vector(x,*n,std::abs(*incx)));
StridedVectorType vy(vector(y,*n,std::abs(*incy))); StridedVectorType vy(make_vector(y,*n,std::abs(*incy)));
Reverse<StridedVectorType> rvx(vx); Reverse<StridedVectorType> rvx(vx);
Reverse<StridedVectorType> rvy(vy); Reverse<StridedVectorType> rvy(vy);
@ -125,9 +126,8 @@ int EIGEN_CAT(EIGEN_CAT(SCALAR_SUFFIX,REAL_SCALAR_SUFFIX),scal_)(int *n, RealSca
// std::cerr << "__scal " << *n << " " << alpha << " " << *incx << "\n"; // std::cerr << "__scal " << *n << " " << alpha << " " << *incx << "\n";
if(*incx==1) vector(x,*n) *= alpha; if(*incx==1) make_vector(x,*n) *= alpha;
else vector(x,*n,std::abs(*incx)) *= alpha; else make_vector(x,*n,std::abs(*incx)) *= alpha;
return 0; return 0;
} }

View File

@ -17,11 +17,11 @@ int EIGEN_BLAS_FUNC(axpy)(int *n, RealScalar *palpha, RealScalar *px, int *incx,
if(*n<=0) return 0; if(*n<=0) return 0;
if(*incx==1 && *incy==1) vector(y,*n) += alpha * vector(x,*n); if(*incx==1 && *incy==1) make_vector(y,*n) += alpha * make_vector(x,*n);
else if(*incx>0 && *incy>0) vector(y,*n,*incy) += alpha * vector(x,*n,*incx); else if(*incx>0 && *incy>0) make_vector(y,*n,*incy) += alpha * make_vector(x,*n,*incx);
else if(*incx>0 && *incy<0) vector(y,*n,-*incy).reverse() += alpha * vector(x,*n,*incx); else if(*incx>0 && *incy<0) make_vector(y,*n,-*incy).reverse() += alpha * make_vector(x,*n,*incx);
else if(*incx<0 && *incy>0) vector(y,*n,*incy) += alpha * vector(x,*n,-*incx).reverse(); else if(*incx<0 && *incy>0) make_vector(y,*n,*incy) += alpha * make_vector(x,*n,-*incx).reverse();
else if(*incx<0 && *incy<0) vector(y,*n,-*incy).reverse() += alpha * vector(x,*n,-*incx).reverse(); else if(*incx<0 && *incy<0) make_vector(y,*n,-*incy).reverse() += alpha * make_vector(x,*n,-*incx).reverse();
return 0; return 0;
} }
@ -35,7 +35,7 @@ int EIGEN_BLAS_FUNC(copy)(int *n, RealScalar *px, int *incx, RealScalar *py, int
// be carefull, *incx==0 is allowed !! // be carefull, *incx==0 is allowed !!
if(*incx==1 && *incy==1) if(*incx==1 && *incy==1)
vector(y,*n) = vector(x,*n); make_vector(y,*n) = make_vector(x,*n);
else else
{ {
if(*incx<0) x = x - (*n-1)*(*incx); if(*incx<0) x = x - (*n-1)*(*incx);
@ -57,8 +57,8 @@ int EIGEN_CAT(EIGEN_CAT(i,SCALAR_SUFFIX),amax_)(int *n, RealScalar *px, int *inc
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
DenseIndex ret; DenseIndex ret;
if(*incx==1) vector(x,*n).cwiseAbs().maxCoeff(&ret); if(*incx==1) make_vector(x,*n).cwiseAbs().maxCoeff(&ret);
else vector(x,*n,std::abs(*incx)).cwiseAbs().maxCoeff(&ret); else make_vector(x,*n,std::abs(*incx)).cwiseAbs().maxCoeff(&ret);
return ret+1; return ret+1;
} }
@ -68,8 +68,8 @@ int EIGEN_CAT(EIGEN_CAT(i,SCALAR_SUFFIX),amin_)(int *n, RealScalar *px, int *inc
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
DenseIndex ret; DenseIndex ret;
if(*incx==1) vector(x,*n).cwiseAbs().minCoeff(&ret); if(*incx==1) make_vector(x,*n).cwiseAbs().minCoeff(&ret);
else vector(x,*n,std::abs(*incx)).cwiseAbs().minCoeff(&ret); else make_vector(x,*n,std::abs(*incx)).cwiseAbs().minCoeff(&ret);
return ret+1; return ret+1;
} }
@ -143,8 +143,8 @@ int EIGEN_BLAS_FUNC(scal)(int *n, RealScalar *palpha, RealScalar *px, int *incx)
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar alpha = *reinterpret_cast<Scalar*>(palpha); Scalar alpha = *reinterpret_cast<Scalar*>(palpha);
if(*incx==1) vector(x,*n) *= alpha; if(*incx==1) make_vector(x,*n) *= alpha;
else vector(x,*n,std::abs(*incx)) *= alpha; else make_vector(x,*n,std::abs(*incx)) *= alpha;
return 0; return 0;
} }
@ -156,12 +156,11 @@ int EIGEN_BLAS_FUNC(swap)(int *n, RealScalar *px, int *incx, RealScalar *py, int
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py); Scalar* y = reinterpret_cast<Scalar*>(py);
if(*incx==1 && *incy==1) vector(y,*n).swap(vector(x,*n)); if(*incx==1 && *incy==1) make_vector(y,*n).swap(make_vector(x,*n));
else if(*incx>0 && *incy>0) vector(y,*n,*incy).swap(vector(x,*n,*incx)); else if(*incx>0 && *incy>0) make_vector(y,*n,*incy).swap(make_vector(x,*n,*incx));
else if(*incx>0 && *incy<0) vector(y,*n,-*incy).reverse().swap(vector(x,*n,*incx)); else if(*incx>0 && *incy<0) make_vector(y,*n,-*incy).reverse().swap(make_vector(x,*n,*incx));
else if(*incx<0 && *incy>0) vector(y,*n,*incy).swap(vector(x,*n,-*incx).reverse()); else if(*incx<0 && *incy>0) make_vector(y,*n,*incy).swap(make_vector(x,*n,-*incx).reverse());
else if(*incx<0 && *incy<0) vector(y,*n,-*incy).reverse().swap(vector(x,*n,-*incx).reverse()); else if(*incx<0 && *incy<0) make_vector(y,*n,-*incy).reverse().swap(make_vector(x,*n,-*incx).reverse());
return 1; return 1;
} }

View File

@ -19,8 +19,8 @@ RealScalar EIGEN_BLAS_FUNC(asum)(int *n, RealScalar *px, int *incx)
if(*n<=0) return 0; if(*n<=0) return 0;
if(*incx==1) return vector(x,*n).cwiseAbs().sum(); if(*incx==1) return make_vector(x,*n).cwiseAbs().sum();
else return vector(x,*n,std::abs(*incx)).cwiseAbs().sum(); else return make_vector(x,*n,std::abs(*incx)).cwiseAbs().sum();
} }
// computes a vector-vector dot product. // computes a vector-vector dot product.
@ -33,11 +33,11 @@ Scalar EIGEN_BLAS_FUNC(dot)(int *n, RealScalar *px, int *incx, RealScalar *py, i
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
Scalar* y = reinterpret_cast<Scalar*>(py); Scalar* y = reinterpret_cast<Scalar*>(py);
if(*incx==1 && *incy==1) return (vector(x,*n).cwiseProduct(vector(y,*n))).sum(); if(*incx==1 && *incy==1) return (make_vector(x,*n).cwiseProduct(make_vector(y,*n))).sum();
else if(*incx>0 && *incy>0) return (vector(x,*n,*incx).cwiseProduct(vector(y,*n,*incy))).sum(); else if(*incx>0 && *incy>0) return (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,*incy))).sum();
else if(*incx<0 && *incy>0) return (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,*incy))).sum(); else if(*incx<0 && *incy>0) return (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,*incy))).sum();
else if(*incx>0 && *incy<0) return (vector(x,*n,*incx).cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); else if(*incx>0 && *incy<0) return (make_vector(x,*n,*incx).cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
else if(*incx<0 && *incy<0) return (vector(x,*n,-*incx).reverse().cwiseProduct(vector(y,*n,-*incy).reverse())).sum(); else if(*incx<0 && *incy<0) return (make_vector(x,*n,-*incx).reverse().cwiseProduct(make_vector(y,*n,-*incy).reverse())).sum();
else return 0; else return 0;
} }
@ -50,8 +50,8 @@ Scalar EIGEN_BLAS_FUNC(nrm2)(int *n, RealScalar *px, int *incx)
Scalar* x = reinterpret_cast<Scalar*>(px); Scalar* x = reinterpret_cast<Scalar*>(px);
if(*incx==1) return vector(x,*n).stableNorm(); if(*incx==1) return make_vector(x,*n).stableNorm();
else return vector(x,*n,std::abs(*incx)).stableNorm(); else return make_vector(x,*n,std::abs(*incx)).stableNorm();
} }
int EIGEN_BLAS_FUNC(rot)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps) int EIGEN_BLAS_FUNC(rot)(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
@ -64,8 +64,8 @@ int EIGEN_BLAS_FUNC(rot)(int *n, RealScalar *px, int *incx, RealScalar *py, int
Scalar c = *reinterpret_cast<Scalar*>(pc); Scalar c = *reinterpret_cast<Scalar*>(pc);
Scalar s = *reinterpret_cast<Scalar*>(ps); Scalar s = *reinterpret_cast<Scalar*>(ps);
StridedVectorType vx(vector(x,*n,std::abs(*incx))); StridedVectorType vx(make_vector(x,*n,std::abs(*incx)));
StridedVectorType vy(vector(y,*n,std::abs(*incy))); StridedVectorType vy(make_vector(y,*n,std::abs(*incy)));
Reverse<StridedVectorType> rvx(vx); Reverse<StridedVectorType> rvx(vx);
Reverse<StridedVectorType> rvy(vy); Reverse<StridedVectorType> rvy(vy);

View File

@ -57,8 +57,8 @@ int EIGEN_BLAS_FUNC(hemv)(char *uplo, int *n, RealScalar *palpha, RealScalar *pa
if(beta!=Scalar(1)) if(beta!=Scalar(1))
{ {
if(beta==Scalar(0)) vector(actual_y, *n).setZero(); if(beta==Scalar(0)) make_vector(actual_y, *n).setZero();
else vector(actual_y, *n) *= beta; else make_vector(actual_y, *n) *= beta;
} }
if(alpha!=Scalar(0)) if(alpha!=Scalar(0))

View File

@ -58,8 +58,8 @@ int EIGEN_BLAS_FUNC(gemv)(char *opa, int *m, int *n, RealScalar *palpha, RealSca
if(beta!=Scalar(1)) if(beta!=Scalar(1))
{ {
if(beta==Scalar(0)) vector(actual_c, actual_m).setZero(); if(beta==Scalar(0)) make_vector(actual_c, actual_m).setZero();
else vector(actual_c, actual_m) *= beta; else make_vector(actual_c, actual_m) *= beta;
} }
if(code>=4 || func[code]==0) if(code>=4 || func[code]==0)
@ -232,8 +232,8 @@ int EIGEN_BLAS_FUNC(gbmv)(char *trans, int *m, int *n, int *kl, int *ku, RealSca
if(beta!=Scalar(1)) if(beta!=Scalar(1))
{ {
if(beta==Scalar(0)) vector(actual_y, actual_m).setZero(); if(beta==Scalar(0)) make_vector(actual_y, actual_m).setZero();
else vector(actual_y, actual_m) *= beta; else make_vector(actual_y, actual_m) *= beta;
} }
MatrixType mat_coeffs(a,coeff_rows,*n,*lda); MatrixType mat_coeffs(a,coeff_rows,*n,*lda);
@ -246,11 +246,11 @@ int EIGEN_BLAS_FUNC(gbmv)(char *trans, int *m, int *n, int *kl, int *ku, RealSca
int len = end - start + 1; int len = end - start + 1;
int offset = (*ku) - j + start; int offset = (*ku) - j + start;
if(OP(*trans)==NOTR) if(OP(*trans)==NOTR)
vector(actual_y+start,len) += (alpha*actual_x[j]) * mat_coeffs.col(j).segment(offset,len); make_vector(actual_y+start,len) += (alpha*actual_x[j]) * mat_coeffs.col(j).segment(offset,len);
else if(OP(*trans)==TR) else if(OP(*trans)==TR)
actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).transpose() * vector(actual_x+start,len) ).value(); actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).transpose() * make_vector(actual_x+start,len) ).value();
else else
actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).adjoint() * vector(actual_x+start,len) ).value(); actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).adjoint() * make_vector(actual_x+start,len) ).value();
} }
if(actual_x!=x) delete[] actual_x; if(actual_x!=x) delete[] actual_x;
@ -304,11 +304,11 @@ int EIGEN_BLAS_FUNC(tbmv)(char *uplo, char *opa, char *diag, int *n, int *k, Rea
int offset = (ku) - j + start; int offset = (ku) - j + start;
if(OP(*trans)==NOTR) if(OP(*trans)==NOTR)
vector(actual_y+start,len) += (alpha*actual_x[j]) * mat_coeffs.col(j).segment(offset,len); make_vector(actual_y+start,len) += (alpha*actual_x[j]) * mat_coeffs.col(j).segment(offset,len);
else if(OP(*trans)==TR) else if(OP(*trans)==TR)
actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).transpose() * vector(actual_x+start,len) ).value(); actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).transpose() * make_vector(actual_x+start,len) ).value();
else else
actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).adjoint() * vector(actual_x+start,len) ).value(); actual_y[j] += alpha * ( mat_coeffs.col(j).segment(offset,len).adjoint() * make_vector(actual_x+start,len) ).value();
} }
if(actual_x!=x) delete[] actual_x; if(actual_x!=x) delete[] actual_x;
@ -521,4 +521,3 @@ int EIGEN_BLAS_FUNC(tpsv)(char *uplo, char *opa, char *diag, int *n, RealScalar
return 1; return 1;
} }

View File

@ -51,8 +51,8 @@ int EIGEN_BLAS_FUNC(symv) (char *uplo, int *n, RealScalar *palpha, RealScalar *p
if(beta!=Scalar(1)) if(beta!=Scalar(1))
{ {
if(beta==Scalar(0)) vector(actual_y, *n).setZero(); if(beta==Scalar(0)) make_vector(actual_y, *n).setZero();
else vector(actual_y, *n) *= beta; else make_vector(actual_y, *n) *= beta;
} }
int code = UPLO(*uplo); int code = UPLO(*uplo);
@ -366,5 +366,3 @@ int EIGEN_BLAS_FUNC(ger)(int *m, int *n, Scalar *palpha, Scalar *px, int *incx,
return 1; return 1;
} }

View File

@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#if (defined __GNUC__) #if (defined __GNUC__) && (!defined __MINGW32__)
#define EIGEN_WEAK_LINKING __attribute__ ((weak)) #define EIGEN_WEAK_LINKING __attribute__ ((weak))
#else #else
#define EIGEN_WEAK_LINKING #define EIGEN_WEAK_LINKING

View File

@ -33,7 +33,7 @@ function(workaround_9220 language language_works)
file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt
${text}) ${text})
execute_process( execute_process(
COMMAND ${CMAKE_COMMAND} . COMMAND ${CMAKE_COMMAND} . -G "${CMAKE_GENERATOR}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
RESULT_VARIABLE return_code RESULT_VARIABLE return_code
OUTPUT_QUIET OUTPUT_QUIET
@ -64,3 +64,4 @@ endfunction(workaround_9220)
#message("CXX_language_works = ${CXX_language_works}") #message("CXX_language_works = ${CXX_language_works}")
#workaround_9220(CXXp CXXp_language_works) #workaround_9220(CXXp CXXp_language_works)
#message("CXXp_language_works = ${CXXp_language_works}") #message("CXXp_language_works = ${CXXp_language_works}")

View File

@ -64,14 +64,14 @@ EIGEN_LAPACK_FUNC(syev,(char *jobz, char *uplo, int* n, Scalar* a, int *lda, Sca
if(eig.info()==NoConvergence) if(eig.info()==NoConvergence)
{ {
vector(w,*n).setZero(); make_vector(w,*n).setZero();
if(computeVectors) if(computeVectors)
matrix(a,*n,*n,*lda).setIdentity(); matrix(a,*n,*n,*lda).setIdentity();
//*info = 1; //*info = 1;
return 0; return 0;
} }
vector(w,*n) = eig.eigenvalues(); make_vector(w,*n) = eig.eigenvalues();
if(computeVectors) if(computeVectors)
matrix(a,*n,*n,*lda) = eig.eigenvectors(); matrix(a,*n,*n,*lda) = eig.eigenvectors();

View File

@ -127,46 +127,47 @@ template<typename Func> void forward_jacobian(const Func& f)
VERIFY_IS_APPROX(j, jref); VERIFY_IS_APPROX(j, jref);
} }
// TODO also check actual derivatives!
void test_autodiff_scalar() void test_autodiff_scalar()
{ {
std::cerr << foo<float>(1,2) << "\n"; Vector2f p = Vector2f::Random();
typedef AutoDiffScalar<Vector2f> AD; typedef AutoDiffScalar<Vector2f> AD;
AD ax(1,Vector2f::UnitX()); AD ax(p.x(),Vector2f::UnitX());
AD ay(2,Vector2f::UnitY()); AD ay(p.y(),Vector2f::UnitY());
AD res = foo<AD>(ax,ay); AD res = foo<AD>(ax,ay);
std::cerr << res.value() << " <> " VERIFY_IS_APPROX(res.value(), foo(p.x(),p.y()));
<< res.derivatives().transpose() << "\n\n";
} }
// TODO also check actual derivatives!
void test_autodiff_vector() void test_autodiff_vector()
{ {
std::cerr << foo<Vector2f>(Vector2f(1,2)) << "\n"; Vector2f p = Vector2f::Random();
typedef AutoDiffScalar<Vector2f> AD; typedef AutoDiffScalar<Vector2f> AD;
typedef Matrix<AD,2,1> VectorAD; typedef Matrix<AD,2,1> VectorAD;
VectorAD p(AD(1),AD(-1)); VectorAD ap = p.cast<AD>();
p.x().derivatives() = Vector2f::UnitX(); ap.x().derivatives() = Vector2f::UnitX();
p.y().derivatives() = Vector2f::UnitY(); ap.y().derivatives() = Vector2f::UnitY();
AD res = foo<VectorAD>(p); AD res = foo<VectorAD>(ap);
std::cerr << res.value() << " <> " VERIFY_IS_APPROX(res.value(), foo(p));
<< res.derivatives().transpose() << "\n\n";
} }
void test_autodiff_jacobian() void test_autodiff_jacobian()
{ {
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,2>()) )); CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,2>()) ));
CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,3>()) )); CALL_SUBTEST(( forward_jacobian(TestFunc1<double,2,3>()) ));
CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,2>()) )); CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,2>()) ));
CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,3>()) )); CALL_SUBTEST(( forward_jacobian(TestFunc1<double,3,3>()) ));
CALL_SUBTEST(( forward_jacobian(TestFunc1<double>(3,3)) )); CALL_SUBTEST(( forward_jacobian(TestFunc1<double>(3,3)) ));
} }
}
void test_autodiff() void test_autodiff()
{ {
test_autodiff_scalar(); for(int i = 0; i < g_repeat; i++) {
test_autodiff_vector(); CALL_SUBTEST_1( test_autodiff_scalar() );
// test_autodiff_jacobian(); CALL_SUBTEST_2( test_autodiff_vector() );
CALL_SUBTEST_3( test_autodiff_jacobian() );
}
} }