elemfun.m
来自「张量分析工具」· M 代码 · 共 20 行
M
20 行
function a = elemfun(a,fun)%ELEMFUN Manipulate the nonzero elements of a sparse tensor.%% X = ELEMFUN(X,@FUN) modifies the elements of X according to the% function @FUN which should take and array and output an equally% sized array.%% Examples% X = sptenrand([10,10,10],10);% X = elemfun(X,@sqrt) %<-- square root of every entry% X = elemfun(X, @(x) x+1) %<-- increase every entry by 1% X = elemfun(X, @(x) x ~= 0) %<-- change every nonzero to be 1%% See also SPTENSOR, SPFUN.%%Copyright 2007, Tamara Kolda and Brett Bader, Sandia National Labsa.vals = fun(a.vals);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?