PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kkreal2cmplx.m

http://github.com/aludnam/MATLAB
Objective C | 221 lines | 218 code | 3 blank | 0 comment | 59 complexity | 006198fd252f67572ad731003900ba38 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkreal2cmplx 'Output = Input 1 + j(Input 2)'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kreal2cmplx.pane file
  3. %
  4. % Parameters:
  5. % OutputFile: o 'Output', required: 'Resulting output data object'
  6. % InputFile: i1 'Real Input ', optional: 'Input to be used as real component'
  7. % InputFile: i2 'Imaginary Input', optional: 'Input to be used as imaginary component'
  8. %
  9. % Example: o = kkreal2cmplx({i1, i2}, {'o','';'i1','';'i2',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % kreal2cmplx - Output = Input 1 + j(Input 2)
  15. %
  16. % DESCRIPTION
  17. % The "Real to Complex" operator (kreal2cmplx) generates a complex
  18. % Output object (o) containing complex data compiled from the supplied
  19. % source object(s), Real Input (i1) and Imaginary Input (i2). The data
  20. % type of the output, which will be complex or double complex, is
  21. % determined from the highest of the source data types.
  22. % Only one source object must be specified.
  23. %
  24. % "Single Source Object:"
  25. % If only one source object is specified, the other component
  26. % of the complex pair will be the Real Constant (real) or Imaginary
  27. % Constant (imag). If the source object has map data, the
  28. % operation will be performed on the map only. For the single source
  29. % case, location, time, and mask data are not needed or modified.
  30. %
  31. % "Two Source Objects"
  32. % If both real and imaginary source objects are specified, and both contain
  33. % map data and no value data the operation is performed directly on the map,
  34. % and the output object will contain a map. For this case of two sources
  35. % that have no value data, location, time, and mask data are not modified,
  36. % but are transferred to the output.
  37. % If either source object contains both map and value data, then both objects
  38. % must have value data, and the data will be mapped before processing. The
  39. % output object will have value data and no map data.
  40. % If the source objects are the same size, then location and time data
  41. % can be ignored.
  42. % If the source objects are different sizes, then location and time data
  43. % are checked, and if they exist, the real to complex conversion will only
  44. % continue if the grid type is uniform. The destination size will be the
  45. % maximum of both source sizes. If padding is required by the Real Input
  46. % object, it will be padded with the Real Constant. If padding is required
  47. % by the Imaginary Input, it will be padded with the Imaginary Constant.
  48. %
  49. % "Validity Mask"
  50. % If either source object has a validity mask, the destination object will
  51. % get a mask. If both source objects have masks, the masks will be
  52. % combined (logical AND) after processing.
  53. %
  54. % "Failure Modes"
  55. % Real to complex conversion will fail if neither source object is
  56. % supplied; if the source objects do not contain at least value
  57. % or map data; or if either source object is already complex.
  58. %
  59. %
  60. %
  61. % EXAMPLES
  62. %
  63. % "SEE ALSO"
  64. %
  65. % RESTRICTIONS
  66. %
  67. % REFERENCES
  68. %
  69. % COPYRIGHT
  70. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  71. %
  72. function varargout = kkreal2cmplx(varargin)
  73. if nargin ==0
  74. Inputs={};arglist={'',''};
  75. elseif nargin ==1
  76. Inputs=varargin{1};arglist={'',''};
  77. elseif nargin ==2
  78. Inputs=varargin{1}; arglist=varargin{2};
  79. else error('Usage: [out1,..] = kkreal2cmplx(Inputs,arglist).');
  80. end
  81. if size(arglist,2)~=2
  82. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  83. end
  84. narglist={'o', '__output';'i1', '__input';'i2', '__input'};
  85. maxval={0,1,1};
  86. minval={0,1,1};
  87. istoggle=[0,1,1];
  88. was_set=istoggle * 0;
  89. paramtype={'OutputFile','InputFile','InputFile'};
  90. % identify the input arrays and assign them to the arguments as stated by the user
  91. if ~iscell(Inputs)
  92. Inputs = {Inputs};
  93. end
  94. NumReqOutputs=1; nextinput=1; nextoutput=1;
  95. for ii=1:size(arglist,1)
  96. wasmatched=0;
  97. for jj=1:size(narglist,1)
  98. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  99. wasmatched = 1;
  100. was_set(jj) = 1;
  101. if strcmp(narglist{jj,2}, '__input')
  102. if (nextinput > length(Inputs))
  103. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  104. end
  105. narglist{jj,2} = 'OK_in';
  106. nextinput = nextinput + 1;
  107. elseif strcmp(narglist{jj,2}, '__output')
  108. if (nextoutput > nargout)
  109. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  110. end
  111. if (isempty(arglist{ii,2}))
  112. narglist{jj,2} = 'OK_out';
  113. else
  114. narglist{jj,2} = arglist{ii,2};
  115. end
  116. nextoutput = nextoutput + 1;
  117. if (minval{jj} == 0)
  118. NumReqOutputs = NumReqOutputs - 1;
  119. end
  120. elseif isstr(arglist{ii,2})
  121. narglist{jj,2} = arglist{ii,2};
  122. else
  123. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  124. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  125. end
  126. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  127. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  128. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  129. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  130. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  131. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  132. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  133. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  134. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  135. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  136. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  137. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  138. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  139. end
  140. end
  141. end
  142. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  143. narglist{jj,2} = arglist{ii,2};
  144. end
  145. end
  146. end
  147. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  148. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  149. end
  150. end
  151. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  152. for jj=1:size(narglist,1)
  153. if strcmp(paramtype{jj}, 'Toggle')
  154. if (narglist{jj,2} ==0)
  155. narglist{jj,1} = '';
  156. end;
  157. narglist{jj,2} = '';
  158. end;
  159. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  160. narglist{jj,1} = '';
  161. narglist{jj,2} = '';
  162. end;
  163. if strcmp(narglist{jj,2}, '__input')
  164. if (minval{jj} == 0) % meaning this input is required
  165. if (nextinput > size(Inputs))
  166. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  167. else
  168. narglist{jj,2} = 'OK_in';
  169. nextinput = nextinput + 1;
  170. end
  171. else % this is an optional input
  172. if (nextinput <= length(Inputs))
  173. narglist{jj,2} = 'OK_in';
  174. nextinput = nextinput + 1;
  175. else
  176. narglist{jj,1} = '';
  177. narglist{jj,2} = '';
  178. end;
  179. end;
  180. else
  181. if strcmp(narglist{jj,2}, '__output')
  182. if (minval{jj} == 0) % this is a required output
  183. if (nextoutput > nargout & nargout > 1)
  184. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  185. else
  186. narglist{jj,2} = 'OK_out';
  187. nextoutput = nextoutput + 1;
  188. NumReqOutputs = NumReqOutputs-1;
  189. end
  190. else % this is an optional output
  191. if (nargout - nextoutput >= NumReqOutputs)
  192. narglist{jj,2} = 'OK_out';
  193. nextoutput = nextoutput + 1;
  194. else
  195. narglist{jj,1} = '';
  196. narglist{jj,2} = '';
  197. end;
  198. end
  199. end
  200. end
  201. end
  202. if nargout
  203. varargout = cell(1,nargout);
  204. else
  205. varargout = cell(1,1);
  206. end
  207. global KhorosRoot
  208. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  209. w=['"' KhorosRoot];
  210. else
  211. if ispc
  212. w='"C:\Program Files\dip\khorosBin\';
  213. else
  214. [s,w] = system('which cantata');
  215. w=['"' w(1:end-8)];
  216. end
  217. end
  218. [varargout{:}]=callKhoros([w 'kreal2cmplx" '],Inputs,narglist);