x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
operation_sparse.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\numeric\ublas\operation_sparse.hpp
旋转
特效
属性
历史版本
// // Copyright (c) 2000-2002 // Joerg Walter, Mathias Koch // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // #ifndef _BOOST_UBLAS_OPERATION_SPARSE_ #define _BOOST_UBLAS_OPERATION_SPARSE_ #include
// These scaled additions were borrowed from MTL unashamedly. // But Alexei Novakov had a lot of ideas to improve these. Thanks. namespace boost { namespace numeric { namespace ublas { template
BOOST_UBLAS_INLINE M & sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2, M &m, TRI, row_major_tag) { typedef M matrix_type; typedef TRI triangular_restriction; typedef const E1 expression1_type; typedef const E2 expression2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; // ISSUE why is there a dense vector here? vector
temporary (e2 ().size2 ()); temporary.clear (); typename expression1_type::const_iterator1 it1 (e1 ().begin1 ()); typename expression1_type::const_iterator1 it1_end (e1 ().end1 ()); while (it1 != it1_end) { size_type jb (temporary.size ()); size_type je (0); #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION typename expression1_type::const_iterator2 it2 (it1.begin ()); typename expression1_type::const_iterator2 it2_end (it1.end ()); #else typename expression1_type::const_iterator2 it2 (boost::numeric::ublas::begin (it1, iterator1_tag ())); typename expression1_type::const_iterator2 it2_end (boost::numeric::ublas::end (it1, iterator1_tag ())); #endif while (it2 != it2_end) { // temporary.plus_assign (*it2 * row (e2 (), it2.index2 ())); matrix_row
mr (e2 (), it2.index2 ()); typename matrix_row
::const_iterator itr (mr.begin ()); typename matrix_row
::const_iterator itr_end (mr.end ()); while (itr != itr_end) { size_type j (itr.index ()); temporary (j) += *it2 * *itr; jb = (std::min) (jb, j); je = (std::max) (je, j); ++ itr; } ++ it2; } for (size_type j = jb; j < je + 1; ++ j) { if (temporary (j) != value_type/*zero*/()) { // FIXME we'll need to extend the container interface! // m.push_back (it1.index1 (), j, temporary (j)); // FIXME What to do with adaptors? // m.insert (it1.index1 (), j, temporary (j)); if (triangular_restriction::other (it1.index1 (), j)) m (it1.index1 (), j) = temporary (j); temporary (j) = value_type/*zero*/(); } } ++ it1; } return m; } template
BOOST_UBLAS_INLINE M & sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2, M &m, TRI, column_major_tag) { typedef M matrix_type; typedef TRI triangular_restriction; typedef const E1 expression1_type; typedef const E2 expression2_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; // ISSUE why is there a dense vector here? vector
temporary (e1 ().size1 ()); temporary.clear (); typename expression2_type::const_iterator2 it2 (e2 ().begin2 ()); typename expression2_type::const_iterator2 it2_end (e2 ().end2 ()); while (it2 != it2_end) { size_type ib (temporary.size ()); size_type ie (0); #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION typename expression2_type::const_iterator1 it1 (it2.begin ()); typename expression2_type::const_iterator1 it1_end (it2.end ()); #else typename expression2_type::const_iterator1 it1 (boost::numeric::ublas::begin (it2, iterator2_tag ())); typename expression2_type::const_iterator1 it1_end (boost::numeric::ublas::end (it2, iterator2_tag ())); #endif while (it1 != it1_end) { // column (m, it2.index2 ()).plus_assign (*it1 * column (e1 (), it1.index1 ())); matrix_column
mc (e1 (), it1.index1 ()); typename matrix_column
::const_iterator itc (mc.begin ()); typename matrix_column
::const_iterator itc_end (mc.end ()); while (itc != itc_end) { size_type i (itc.index ()); temporary (i) += *it1 * *itc; ib = (std::min) (ib, i); ie = (std::max) (ie, i); ++ itc; } ++ it1; } for (size_type i = ib; i < ie + 1; ++ i) { if (temporary (i) != value_type/*zero*/()) { // FIXME we'll need to extend the container interface! // m.push_back (i, it2.index2 (), temporary (i)); // FIXME What to do with adaptors? // m.insert (i, it2.index2 (), temporary (i)); if (triangular_restriction::other (i, it2.index2 ())) m (i, it2.index2 ()) = temporary (i); temporary (i) = value_type/*zero*/(); } } ++ it2; } return m; } // Dispatcher template
BOOST_UBLAS_INLINE M & sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2, M &m, TRI, bool init = true) { typedef typename M::value_type value_type; typedef TRI triangular_restriction; typedef typename M::orientation_category orientation_category; if (init) m.assign (zero_matrix
(e1 ().size1 (), e2 ().size2 ())); return sparse_prod (e1, e2, m, triangular_restriction (), orientation_category ()); } template
BOOST_UBLAS_INLINE M sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2, TRI) { typedef M matrix_type; typedef TRI triangular_restriction; matrix_type m (e1 ().size1 (), e2 ().size2 ()); // FIXME needed for c_matrix?! // return sparse_prod (e1, e2, m, triangular_restriction (), false); return sparse_prod (e1, e2, m, triangular_restriction (), true); } template
BOOST_UBLAS_INLINE M & sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2, M &m, bool init = true) { typedef typename M::value_type value_type; typedef typename M::orientation_category orientation_category; if (init) m.assign (zero_matrix
(e1 ().size1 (), e2 ().size2 ())); return sparse_prod (e1, e2, m, full (), orientation_category ()); } template
BOOST_UBLAS_INLINE M sparse_prod (const matrix_expression
&e1, const matrix_expression
&e2) { typedef M matrix_type; matrix_type m (e1 ().size1 (), e2 ().size2 ()); // FIXME needed for c_matrix?! // return sparse_prod (e1, e2, m, full (), false); return sparse_prod (e1, e2, m, full (), true); } }}} #endif
operation_sparse.hpp
网页地址
文件地址
上一页
16/26
下一页
下载
( 8 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.