source: MML/trunk/mml/@AccObj/mtimes.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 2.8 KB
Line 
1function AccObj1 = mtimes(AccObj1, AccObj2)
2%MTIMES - Multiplication (A*B) for AccObj class
3%
4%  1. AccObj multiplication
5%     Multiplying 2 AccObj returns an AccObj
6%
7%  2. Matrix multiplication
8%     c*x or x*c, where x is an AccObj and c
9%     is a matrix returns a double matrix
10%
11%  NOTES
12%  1. 1*x is one way to return the data field as a vector.
13%     Same as x(:)
14%
15%  EXAMPLES
16%  1. To get the change in orbit determined from a response
17%     matrix due to the present horizontal corrector set:
18%        hcm = getsp('HCM','Object');
19%        R = getrespmat('BPMx', hcm);
20%        dx = R * hcm;        % dx is a vector
21%
22%  Written by Greg Portmann
23
24
25
26if isnumeric(AccObj2)
27    Families = fieldnames(AccObj1);
28
29    %if isscalar(AccObj2)
30    %    for i = 1:length(Families)
31    %        if ~isempty(AccObj1.(Families{i}))
32    %            AccObj1.(Families{i}).Data = AccObj1.(Families{i}).Data * AccObj2;
33    %        end
34    %    end
35    %else
36        d = [];
37        for i = 1:length(Families)
38            %if ~isempty(AccObj1.(Families{i}))
39                d = [d; AccObj1.(Families{i}).Data];
40            %end
41        end
42
43        AccObj1 = d * AccObj2;
44    %end
45
46elseif isnumeric(AccObj1)
47    Families = fieldnames(AccObj2);
48
49    %if isscalar(AccObj1)
50    %   for i = 1:length(Families)
51    %       if ~isempty(AccObj2.(Families{i}))
52    %           AccObj2.(Families{i}).Data = AccObj1 * AccObj2.(Families{i}).Data;
53    %       end
54    %   end
55    %   AccObj1 = AccObj2;
56    %else
57        d = [];
58        for i = 1:length(Families)
59            %if ~isempty(AccObj2.(Families{i}))
60                d = [d; AccObj2.(Families{i}).Data];
61            %end
62        end
63
64        AccObj1 = AccObj1 * d;
65    %end
66
67
68else
69    % Combine the lists
70    %error('There is a device in one BPM object that is not is the other.');
71
72    Families = fieldnames(getao);
73
74    for i = 1:length(Families)
75        if ~isempty(AccObj1.(Families{i})) & ~isempty(AccObj2.(Families{i}))
76            [DeviceList, i1, i2] = union(AccObj1.(Families{i}).DeviceList, AccObj2.(Families{i}).DeviceList, 'rows');
77            Data1 = zeros(size(DeviceList,1),1);
78            Data2 = Data1;
79
80            j = findrowindex(AccObj1.(Families{i}).DeviceList, DeviceList);
81            Data1(j) = AccObj1.(Families{i}).Data;
82
83            j = findrowindex(AccObj2.(Families{i}).DeviceList, DeviceList);
84            Data2(j) = AccObj2.(Families{i}).Data;
85
86            Data = Data1 .* Data2;
87
88            AccObj1.(Families{i}).Data = Data;
89            AccObj1.(Families{i}).DeviceList = DeviceList;
90
91        elseif ~isempty(AccObj2.(Families{i}))
92            % Move family in AccObj2 to AccObj1  ???
93            AccObj1.(Families{i}) = AccObj2.(Families{i});
94            AccObj1.(Families{i}).Data = AccObj1.(Families{i}).Data;
95        end
96    end
97   
98    d = AccObj1;
99end
100
101
Note: See TracBrowser for help on using the repository browser.