Switch to unified view

a b/functions/@mmo/ctranspose.m
1
function res = ctranspose(obj,useconj);
2
    if nargin == 1
3
        useconj = 1;
4
    end
5
6
    if length(obj.dimensions) > 2
7
        error('Cannot transpose array');
8
    end
9
    
10
    % make new memory mapped data file
11
    % --------------------------------
12
    newFileName = mmo.getnewfilename;
13
    copyfile(obj.dataFile, newFileName);
14
    
15
    res = obj;
16
    res.dimensions = [ obj.dimensions(2) obj.dimensions(1) ];
17
    res.dataFile = newFileName;
18
    tmpMMO1 = memmapfile(obj.dataFile, 'writable', obj.writable, 'format', { 'single' obj.dimensions 'x' });
19
    tmpMMO2 = memmapfile(res.dataFile, 'writable',         true, 'format', { 'single' res.dimensions 'x' });
20
    
21
    % copy the data
22
    % -------------
23
    if length(obj.dimensions) == 1 || obj.dimensions(1) > obj.dimensions(2)
24
        for index = 1:size(obj,2)
25
            s.type = '()';
26
            s.subs = { ':' index };
27
            if useconj, tmpMMO2.Data.x(index,:) = conj(subsref(tmpMMO1.Data.x,s));
28
            else        tmpMMO2.Data.x(:,index) =      subsref(tmpMMO1.Data.x,s);
29
            end
30
        end
31
    else
32
        for index = 1:size(obj,1)
33
            s.type = '()';
34
            s.subs = { index ':' };
35
            if useconj, tmpMMO2.Data.x(:,index) = conj(subsref(tmpMMO1.Data.x,s));
36
            else        tmpMMO2.Data.x(:,index) =      subsref(tmpMMO1.Data.x,s);
37
            end
38
        end
39
    end
40