|
53 | 53 | % tensor 'tExistingTensor' into a MappedTensor, of the appropriate class. |
54 | 54 | % |
55 | 55 | % The optional argument 'Like' allows you to create a MappedTensor with the |
56 | | -% same class and complexity (i.e. real and complex) of 'tExistingTensor'. |
| 56 | +% same class and complexity (i.e. real or complex) of 'tExistingTensor'. |
57 | 57 | % Note that sparse MappedTensors are not supported. |
58 | 58 | % |
59 | 59 | % Usage: size(mtVariable) |
|
78 | 78 | % times (A*B, A.*B) as long as one of A or B is a scalar. Divide (A/B, |
79 | 79 | % A./B, B\A, B.\A) is supported, as long as B is a scalar. |
80 | 80 | % |
| 81 | +% Transparent casting to other classes is supported in O(1) time. Note that |
| 82 | +% due to transparent casting and tranparent O(1) scaling, rounding may |
| 83 | +% occur in a different class to the returned data, and therefore may not |
| 84 | +% match matlab rounding precisely. If this is an issue, index the tensor |
| 85 | +% and then scale the returned values rather than rely on O(1) scaling of |
| 86 | +% the entire tensor. |
| 87 | +% |
81 | 88 | % Save and load is minimally supported -- data is NOT saved, but on load a new |
82 | 89 | % mapped tensor will be generated and filled with zeros. Both save and load |
83 | 90 | % generate warnings. |
@@ -524,9 +531,9 @@ function delete(mtVar) |
524 | 531 | else |
525 | 532 | tfData = mtVar.fRealFactor .* tfData; |
526 | 533 | end |
527 | | - |
528 | | - % - Recast data, if required, to take into account scaling in |
529 | | - % other class |
| 534 | + |
| 535 | + % - Recast data, if required, to take into account scaling which |
| 536 | + % can occur in another class |
530 | 537 | if (mtVar.bMustCast) |
531 | 538 | tfData = cast(tfData, mtVar.strClass); |
532 | 539 | end |
@@ -565,20 +572,26 @@ function delete(mtVar) |
565 | 572 |
|
566 | 573 | % - Cast data, if required |
567 | 574 | if (mtVar.bMustCast) |
568 | | - tfData = cast(tfData, mtVar.strStorageClass); |
| 575 | + if (mtVar.bIsComplex) |
| 576 | + tfData = complex(cast(real(tfData) ./ mtVar.fRealFactor, mtVar.strStorageClass), ... |
| 577 | + cast(imag(tfData) ./ mtVar.fComplexFactor, mtVar.strStorageClass)); |
| 578 | + |
| 579 | + else |
| 580 | + tfData = cast(tfData ./ mtVar.fRealFactor, mtVar.strStorageClass); |
| 581 | + end |
569 | 582 | end |
570 | 583 |
|
571 | 584 | % - Permute input data |
572 | 585 | tfData = ipermute(tfData, mtVar.vnDimensionOrder); |
573 | 586 |
|
574 | 587 | if (~isreal(tfData)) || (~isreal(mtVar)) |
575 | 588 | % - Assign to both real and complex parts |
576 | | - mt_write_data(mtVar.hShimFunc, mtVar.hRealContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, real(tfData) ./ mtVar.fRealFactor, mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
577 | | - mt_write_data(mtVar.hShimFunc, mtVar.hCmplxContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, imag(tfData) ./ mtVar.fComplexFactor, mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
| 589 | + mt_write_data(mtVar.hShimFunc, mtVar.hRealContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, real(tfData), mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
| 590 | + mt_write_data(mtVar.hShimFunc, mtVar.hCmplxContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, imag(tfData), mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
578 | 591 |
|
579 | 592 | else |
580 | 593 | % - Assign only real part |
581 | | - mt_write_data(mtVar.hShimFunc, mtVar.hRealContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, tfData ./ mtVar.fRealFactor, mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
| 594 | + mt_write_data(mtVar.hShimFunc, mtVar.hRealContent, S, mtVar.vnOriginalSize, mtVar.strStorageClass, mtVar.nHeaderBytes, tfData, mtVar.bBigEndian, mtVar.hRepSumFunc, mtVar.hChunkLengthFunc); |
582 | 595 | end |
583 | 596 | end |
584 | 597 |
|
@@ -744,6 +757,11 @@ function delete(mtVar) |
744 | 757 | bIsInteger = ~isfloat(mtVar) & ~islogical(mtVar) & ~ischar(mtVar); |
745 | 758 | end |
746 | 759 |
|
| 760 | + % strfind - METHOD Overloaded strfind function |
| 761 | + function [nLoc] = strfind(mtVar, varargin) %#ok<INUSD> |
| 762 | + nLoc =[]; |
| 763 | + end |
| 764 | + |
747 | 765 | %% Overloaded methods (uminus, uplus, times, mtimes, ldivide, rdivide, mldivide, mrdivide) |
748 | 766 |
|
749 | 767 | % uminus - METHOD Overloaded uminus operator (-mtVar) |
|
0 commit comments