Dominant arguments and gpuArray
이전 댓글 표시
"The dominant argument in a method's argument list determines which version of the method or function that the MATLAB runtime calls. Dominance is determined by the relative precedences of the classes of the arguments. In general, user-defined classes take precedence over built-in MATLAB classes"
However, I'm finding that gpuArrays take precedence over user-defined classes in the example below
classdef myclass
methods
function mldivide(x,y)
disp ' '
disp 'myclass mldivide method called'
disp ' '
end
end
end
>> which mldivide( gpuArray(1) , myclass)
mldivide is a built-in method % gpuArray method
Why does gpuArray, which is a built-in class, take precedence over my user-supplied class, contrary to the documentation?
채택된 답변
추가 답변 (1개)
Alexander Jensen
2018년 9월 7일
편집: Alexander Jensen
2018년 9월 7일
I believe that what ever computation run within the class will choose the function you've defined in your class, however, calling the function outside of your class requires you to write:
myclass.mldivide(x,y)
Also:
which myclass.mldivide
However I might be wrong :)
카테고리
도움말 센터 및 File Exchange에서 Execution Speed에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!