[英]C++ boost ublas + units dimension constraints
我正在尋求有關如何使用增強單元強制對ublas矩陣/向量進行矩陣維數約束的設計/總體思路的建議。
例如,讓矩陣A具有時間x力的維度(例如)
// does not have dimensions, time x force and force x time are not distinguished.
matrix<double> A;
//something like?
dimension<time, force, matrix<double> > A;
dimension<force, time, matrix<double> > B = trans(A);
// or maybe custom layouts, although ensuring dimension becomes harder between matrixes?
matrix<double, dimension<time, force> > A;
你有沒有做過這樣的事情,或者你對如何組織這些約束有一些好主意? 我正在尋找更多的語法/語義建議而不是實現。
我已經通過ublas檔案,有一些討論,但沒有具體的。
謝謝
看看這個漂亮的Boost教程,它使用模板元編程引入了尺寸分析功能:
http://www.boost.org/doc/libs/1_35_0/libs/mpl/doc/tutorial/representing-dimensions.html
這將要求您為要在應用中使用的每個維度創建一整套模板特化,但結果是值得的 - 它不會讓您犯錯或在尺寸中添加歧義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.