/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/sym_g.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/sym_g.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Tue Feb 7 00:13:27 2012 UTC (13 years, 5 months ago) by gforget
Branch: MAIN
Changes since 1.2: +10 -8 lines
- add sym_in==0 case, which just returns the input field
  as the output, without applying any reflexion or rotation.

1 gforget 1.1 function [field_out]=sym_g(field_in,sym_in,op_in);
2     %apply symmetry in the complex plane to field_in(z)
3 gforget 1.3 % where field_in and z are in the complex arrays.
4 gforget 1.1 %then, depending on op_in, we apply a compensating operation
5     %
6     %format of field_in:
7 gforget 1.3 % z(1,:) is z=-1+?i, z(end,:) is z=1+?i
8     % z(:,1) is z=?-i, z(:,end) is z=?+i
9 gforget 1.1 %
10 gforget 1.3 %sym_in: 1,2,3,4 are reflexions about x=0,y=0,x=y,x=-y
11     % 4+nRot is rotation by nRot*pi/2
12     % 0 just returns the input field as output
13     %op_in: 1 apply the opposite complex operation
14 gforget 1.1
15     field_out=field_in;
16 gforget 1.2 if isempty(whos('op_in')); op_in=0; end;
17 gforget 1.1
18 gforget 1.3 if sym_in==0;
19     %do nothing
20     elseif sym_in==1;
21 gforget 1.1 field_out=flipdim(field_in,1);
22     if op_in==1; field_out=-real(field_out)+i*imag(field_out); end;
23     elseif sym_in==2;
24     field_out=flipdim(field_in,2);
25     if op_in==1; field_out=real(field_out)-i*imag(field_out); end;
26     elseif sym_in==3;
27     field_out=field_in.';
28     if op_in==1; field_out=imag(field_out)+i*real(field_out); end;
29     elseif sym_in==4;
30     field_out=flipdim(flipdim(field_in,1).',1);
31     if op_in==1; field_out=-imag(field_out)-i*real(field_out); end;
32     elseif sym_in>=5&sym_in<=7;
33     for icur=1:sym_in-4;
34     field_out=flipdim(field_out.',1);
35     if op_in==1; field_out=i*field_out; end;
36     end
37     else;
38     fprintf('error in sym_g2\n'); return;
39     end;
40    
41     %for test case:
42     %--------------
43     %xx=[1:10]'*ones(1,10); yy=xx';
44     %zz=zeros(10,10); zz(1:2,1:3)=1; zz(8,9)=2; zz(2,6:8)=-1; zz(7,3)=-2;
45     %sym_g(zz,1); %etc
46     %with the following uncommented:
47     %-------------------------------
48     %figure;
49     %subplot(2,2,1); imagesc(field_in);
50     %subplot(2,2,4); imagesc(field_out);
51     %xlabel('y'); xlabel('x');
52    
53    

  ViewVC Help
Powered by ViewVC 1.1.22