direct_access.cpp

来自「矩阵运算源码最新版本」· C++ 代码 · 共 35 行

CPP
35
字号
// Software License for MTL// // Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.// Authors: Peter Gottschling and Andrew Lumsdaine// // This file is part of the Matrix Template Library// // See also license.mtl.txt in the distribution.#include <boost/numeric/mtl/mtl.hpp>#include <iostream>#include <boost/test/minimal.hpp>int test_main(int argc, char* argv[]){    using namespace mtl; using namespace mtl::matrix;        const unsigned n= 100;    dense2D<double>                            A(n, n);    morton_dense<double, doppled_64_row_mask>  C(n, n);    A[0][0]= 71.; C[0][0]= 72.;    double *ap= &A[0][0], *cp= &C[0][0];    std::cout << *ap << '\n';    if (*ap != 71) throw "wrong value";    // the direct access of the first element should only be used when absolutely necessary     double *ap2= A.elements(), *cp2= C.elements();    std::cout << *ap2 << '\n';    if (*ap2 != 71) throw "wrong value";    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?