主要内容

pagefun

将功能应用于分布式数组或GPUARRAY的每个页面

描述

一种= pagefun(乐趣,,,,b应用由乐趣到分布式阵列或gpuarray的每个页面b。结果一种包含结果的每一页,以便a(::,:,i,j,...)=有趣(b(:,:,i,j,...)))一种is a distributed array or a gpuArray, depending on the array type ofb乐趣是采用二维输入参数的函数的句柄。

例子

一种= pagefun(乐趣,,,,B1,...,bn评估乐趣使用阵列的页面B1,...,bn作为具有标量扩展的输入参数。几乎可以复制标量的任何输入页面维度,以匹配该维度的其他数组的大小,以便a(:,:,i,j,...)= fun(b1(:,:,i,j,...),...,bn(:,:,:,i,j,...)))。输入页b(:,:,i,j,...),...,bn(:,:,i,j,...),必须满足所有输入要求乐趣

If you plan to make several calls topagefun,首先将该数组转换为分布式数组或GPUARRAY更有效。

[[A1,...,AM] = pagefun(乐趣,,,,___返回多个输出数组A1,...,AM当功能时乐趣返回m输出值。pagefun呼叫乐趣每次都有与呼吁中尽可能多的输出pagefun, 那是,m时代。如果您打电话pagefunwith more output arguments than supported by乐趣,Matlab®生成错误。乐趣可以返回具有不同数据类型的输出参数,但是每次输出的数据类型必须相同乐趣叫做。

例子

全部收缩

此示例显示了如何使用pagefun应用mtimes功能到两个GPU数组的每个页面,bandC

创建两个GPU阵列,bandC

M = 3;% output number of rowsK = 6;%矩阵倍数内尺寸n = 2;列的输出数量%p1 = 10;第一页维度的百分比P2 = 17;% size of second page dimensionP3 = 4;第三页维度的百分比p4 = 12;第四页维度的百分比a = rand(m,k,p1,1,p3,'gpuarray');b = rand(k,n,1,p2,p3,p4,'gpuarray');

称呼pagefun应用mtimes函数对这两个阵列的每个页面。

c = pagefun(@mtimes,a,b);s = size(c)%m-by-n-by-p1 by-p2 by-p3 by-p4
S = 3 2 10 17 4 12

此代码显示了另一个类似的用例pagefun功能。

M = 300;% output number of rowsk = 500;%矩阵倍数内尺寸n = 1000;列的输出数量%p = 200;% 页数a = rand(m,k,'gpuarray');b = rand(k,n,p,'gpuarray');c = pagefun(@mtimes,a,b);s = size(c)%返回m-n-by-p
S = 300 1000 200

输入参数

全部收缩

Function applied to each page of the inputs, specified as a function handle. For each output argument,乐趣每次调用同一类都必须返回值的值。

The supported values for乐趣include:

  • 大多数元素分布式阵列和GPUARRAY功能

  • @ctranspose

  • @conv

  • @fliplr

  • @flipud

  • @inv

  • @mldivide

  • @mrdivide

  • @mtimes

  • @rot90

  • @transpose

  • @tril

  • @triu

如果输入分布数组,supporte万博1manbetxd values for乐趣also include:

  • @conv2

  • @lu

  • @规范

  • @qr

  • @SVD

输入数组,指定为分布式数组或GPUARRAY。

输入数组,指定为分布式数组,GPUARRARES或数组。至少一个输入B1,...,bn,,,,must be a distributed array or gpuArray. Using both distributed array and gpuArray as inputs is not supported. Each array that is stored in CPU memory is converted to a distributed array or gpuArray before the function is evaluated. If you plan to make several calls topagefunwith the same array, it is more efficient to first convert that array to a distributed array or a gpuArray.

输出参数

全部收缩

输出数组,返回为分布式数组或GPUARRAY。

也可以看看

|||

在R2013B中引入