source: MML/trunk/machine/SOLEIL/StorageRing/insertions/IDStarter/idAuxCombMatrWeighted.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: 1.1 KB
Line 
1function mRes = idAuxCombMatrWeighted(m1, w1, m2, w2, startInd1, endInd1, startInd2, endInd2)
2
3wNormInv = 1./sqrt(w1*w1 + w2*w2);
4w1 = w1*wNormInv;
5w2 = w2*wNormInv;
6
7sizeDim1 = size(m1, 1);
8sizeDim2 = size(m1, 2);
9sizeDim1_m2 = size(m2, 1);
10sizeDim2_m2 = size(m2, 2);
11
12if(sizeDim1 > sizeDim1_m2)
13        sizeDim1 = sizeDim1_m2;
14end
15if(sizeDim2 > sizeDim2_m2)
16        sizeDim2 = sizeDim2_m2;
17end
18
19mRes = m1;
20if(startInd1 <= 0)
21    startInd1 = 1;
22end
23if(endInd1 <= 0)
24    endInd1 = sizeDim1;
25end
26if(startInd2 <= 0)
27    startInd2 = 1;
28end
29if(endInd2 <= 0)
30    endInd2 = sizeDim2;
31end
32
33if(startInd1 > sizeDim1)
34    sprintf('Inconsistent start value of Index 1');
35    return;
36end
37if(startInd2 > sizeDim2)
38    sprintf('Inconsistent start value of Index 2');
39    return;
40end
41if(endInd1 > sizeDim1)
42    sprintf('Inconsistent end value of Index 1');
43    endInd1 = sizeDim1;
44end
45if(endInd2 > sizeDim2)
46    sprintf('Inconsistent end value of Index 2');
47    endInd2 = sizeDim2;
48end
49
50for i1 = startInd1:endInd1
51    for i2 = startInd2:endInd2
52        mRes(i1, i2) = w1*m1(i1, i2) + w2*m2(i1, i2);
53    end
54end
Note: See TracBrowser for help on using the repository browser.