Bugzilla – Attachment 799 Details for
Bug 1480
Sparse routines do not properly support AD scalar types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
Demonstrates problem using eigens AutoDiffScalar type.
eigen_ad.cpp (text/x-c++src), 1.37 KB, created by
Brad Bell
on 2017-10-28 02:47:09 UTC
(
hide
)
Description:
Demonstrates problem using eigens AutoDiffScalar type.
Filename:
MIME Type:
Creator:
Brad Bell
Created:
2017-10-28 02:47:09 UTC
Size:
1.37 KB
patch
obsolete
># include <iostream> ># include <Eigen/Sparse> ># include <eigen3/unsupported/Eigen/AutoDiff> >int main(void) >{ > typedef Eigen::AutoDiffScalar<Eigen::VectorXd> a_scalar; > typedef Eigen::Matrix<a_scalar, Eigen::Dynamic, 1> a_vector; > // > typedef Eigen::SparseMatrix<a_scalar, Eigen::ColMajor> sparse_matrix; > typedef Eigen::SparseLU<sparse_matrix> sparse_solver; > typedef sparse_matrix::InnerIterator column_itr; > // > a_scalar a; > // > // declare independent variable vector > int n = 2; > sparse_matrix a_x(n, 1); > // > // first independent variable > a = 0.0; > a.derivatives() = Eigen::VectorXd::Unit(n,0); > a_x.insert(0, 0) = a; > // > // second independent variable > a = 4.0; > a.derivatives() = Eigen::VectorXd::Unit(n, 1); > a_x.insert(1, 0) = a; > // > // Identity matrix > sparse_matrix a_eye(n, n); > for(int i = 0; i < n; i++) > a_eye.insert(i, i) = 1.0; > // > sparse_solver solver; > solver.analyzePattern(a_eye); > solver.factorize(a_eye); > // > // Instantiate a dependent variable > sparse_matrix a_y = solver.solve( a_x ); > // > for(column_itr itr(a_y, 0); itr; ++itr) > { int r = itr.row(); > int c = itr.col(); > a = itr.value(); > assert( c == 0 ); > for(int j = 0; j < n; j++) > std::cout << "dy" << r << "_dx" << j << " = " << > a.derivatives()[j] << "\n"; > } > std::cout << "Note that y = x so dy0_dx0 should be 1 but is missing.\n"; > // > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1480
: 799