contiguous.cpp

来自「数值计算工具库,C语言编写的,可以直接调用.」· C++ 代码 · 共 44 行

CPP
44
字号
#include "testsuite.h"
#include <blitz/array.h>

BZ_USING_NAMESPACE(blitz)

int main()
{
  {
    Array<int, 2> A(7,11);
    BZTEST(A.isStorageContiguous());

    BZTEST(!(A(Range(fromStart, toEnd, 2), 
        Range::all())).isStorageContiguous());
    BZTEST(A.reverse(firstDim).isStorageContiguous());
    BZTEST(A.reverse(secondDim).isStorageContiguous());
    BZTEST(!A(Range::all(), 4).isStorageContiguous());
    BZTEST(A(4, Range::all()).isStorageContiguous());
  }

  {
    Array<int, 2> A(7,11,fortranArray);
    BZTEST(A.isStorageContiguous());

    BZTEST(!(A(Range(fromStart, toEnd, 2), 
        Range::all())).isStorageContiguous());
    BZTEST(A.reverse(firstDim).isStorageContiguous());
    BZTEST(A.reverse(secondDim).isStorageContiguous());
    BZTEST(A(Range::all(), 4).isStorageContiguous());
    BZTEST(!A(4, Range::all()).isStorageContiguous());
  }

  {
    Array<int, 2> A(Range(-4,8),Range(4,27));
    BZTEST(A.isStorageContiguous());

    BZTEST(!(A(Range(fromStart, toEnd, 2), 
        Range::all())).isStorageContiguous());
    BZTEST(A.reverse(firstDim).isStorageContiguous());
    BZTEST(A.reverse(secondDim).isStorageContiguous());
    BZTEST(!A(Range::all(), 4).isStorageContiguous());
    BZTEST(A(4, Range::all()).isStorageContiguous());
  }
}

⌨️ 快捷键说明

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