|
74 | 74 | % Transposition just swaps the first two dimensions, leaving the trailing |
75 | 75 | % dimensions unpermuted. |
76 | 76 | % |
77 | | -% Unary plus (+A) and minus (-A) are supported. Binary plus (A+B), minus (A-B), |
78 | | -% times (A*B, A.*B) as long as one of A or B is a scalar. Divide (A/B, |
79 | | -% A./B, B\A, B.\A) is supported, as long as B is a scalar. |
| 77 | +% Unary plus (+A) and minus (-A) are supported. Binary plus (A+B) and |
| 78 | +% minus (A-B) are not supported, since they require a full load of the |
| 79 | +% tensor to implement. Perform addition or subtraction on a referenced |
| 80 | +% portion of the tensor, or use SliceFunction to perform the operation. |
| 81 | +% Multiplication using times (A*B, A.*B) is supported as long as one of A |
| 82 | +% or B is a scalar. Divide (A/B, A./B, B\A, B.\A) is supported, as long as |
| 83 | +% B is a scalar. |
80 | 84 | % |
81 | 85 | % Transparent casting to other classes is supported in O(1) time. Note that |
82 | 86 | % due to transparent casting and tranparent O(1) scaling, rounding may |
@@ -856,67 +860,15 @@ function delete(mtVar) |
856 | 860 | %% Overloaded methods (plus, minus) |
857 | 861 |
|
858 | 862 | % plus - METHOD Overloaded binary 'plus' operator (A+B) |
859 | | - function [mtVar] = plus(varargin) |
860 | | - % - Are the inputs numeric? |
861 | | - vbIsNumeric = cellfun(@isnumeric, varargin); |
862 | | - |
863 | | - % - Are the inputs scalar? |
864 | | - vbIsScalar = cellfun(@isscalar, varargin); |
865 | | - |
866 | | - % - Are the inputs of class MappedTensor |
867 | | - vbIsTensor = cellfun(@(o)(isa(o, 'MappedTensor')), varargin); |
868 | | - |
869 | | - % - Can we perform the operation? |
870 | | - if (nnz(vbIsNumeric & vbIsScalar & ~vbIsTensor) ~= 1) |
871 | | - error('MappedTensor:InvalidPlusOperands', ... |
872 | | - '*** MappedTensor: ''plus'' (A+B) is only supported for a MappedTensor object and a scalar.'); |
873 | | - end |
874 | | - |
875 | | - % - Get the scalar value |
876 | | - fScalar = varargin{vbIsNumeric & vbIsScalar}; |
877 | | - mtVar = varargin{vbIsTensor}; |
878 | | - |
879 | | - % - Find a dimension to slice along |
880 | | - vnTensorSize = size(mtVar); |
881 | | - nSliceDim = numel(vnTensorSize); |
882 | | - |
883 | | - % - Perform the addition slice-wise |
884 | | - fhAddition = @(tSlice)(tSlice + fScalar); |
885 | | - SliceFunction(mtVar, fhAddition, nSliceDim); |
| 863 | + function [varargout] = plus(varargin) %#ok<STOUT> |
| 864 | + error('MappedTensor:NotImplemented', ... |
| 865 | + '*** MappedTensor: ''plus'' (A+B) must be performed on a referenced portion of the tensor, or else explicitly with ''SliceFunction''.'); |
886 | 866 | end |
887 | 867 |
|
888 | 868 | % minus - METHOD Overloaded binary 'minus' operator (A-B) |
889 | | - function [mtVar] = minus(varargin) |
890 | | - % - Are the inputs numeric? |
891 | | - vbIsNumeric = cellfun(@isnumeric, varargin); |
892 | | - |
893 | | - % - Are the inputs scalar? |
894 | | - vbIsScalar = cellfun(@isscalar, varargin); |
895 | | - |
896 | | - % - Are the inputs of class MappedTensor |
897 | | - vbIsTensor = cellfun(@(o)(isa(o, 'MappedTensor')), varargin); |
898 | | - |
899 | | - % - Can we perform the operation? |
900 | | - if (nnz(vbIsNumeric & vbIsScalar & ~vbIsTensor) ~= 1) |
901 | | - error('MappedTensor:InvalidMinusOperands', ... |
902 | | - '*** MappedTensor: ''minus'' (A-B) is only supported for a MappedTensor object and a scalar.'); |
903 | | - end |
904 | | - |
905 | | - % - Get the scalar value |
906 | | - fScalar = varargin{vbIsNumeric & vbIsScalar}; |
907 | | - mtVar = varargin{vbIsTensor}; |
908 | | - |
909 | | - % - Find a dimension to slice along |
910 | | - vnTensorSize = size(mtVar); |
911 | | - nSliceDim = numel(vnTensorSize); |
912 | | - |
913 | | - % - Perform the subtraction slice-wise |
914 | | - if (vbIsScalar(1)) |
915 | | - fhSubtraction = @(tSlice)(fScalar - tSlice); |
916 | | - else |
917 | | - fhSubtraction = @(tSlice)(tSlice - fScalar); |
918 | | - end |
919 | | - SliceFunction(mtVar, fhSubtraction, nSliceDim); |
| 869 | + function [varargout] = minus(varargin) %#ok<STOUT> |
| 870 | + error('MappedTensor:NotImplemented', ... |
| 871 | + '*** MappedTensor: ''minus'' (A-B) must be performed on a referenced portion of the tensor, or else explicitly with ''SliceFunction''.'); |
920 | 872 | end |
921 | 873 |
|
922 | 874 | %% disp - METHOD Overloaded disp function |
|
0 commit comments