PageRenderTime 42ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kkldexp.m

http://github.com/aludnam/MATLAB
Objective C | 221 lines | 221 code | 0 blank | 0 comment | 1 complexity | 57322e176df91c9f7f3eeee35a96c096 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkldexp 'Output = Input 1 * 2**(Input 2 or Constant)'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kldexp.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input 1', required: 'First input data object'
  6. % OutputFile: o 'Output', required: 'Resulting output data object'
  7. % InputFile: i2 'Input 2', optional: 'Second input data object'
  8. %
  9. % Example: o = kkldexp({i1, i2}, {'i1','';'o','';'i2',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % kldexp - Output = Input 1 * 2**(Input 2 or Constant)
  15. %
  16. % DESCRIPTION
  17. % The "ldexp" operator multiplies each point in \fBInput 1\fP with the
  18. % result of 2 taken to the power of either \fBInput 2" or the \fBConstant\fP
  19. % value, whichever is specified by the user.
  20. %
  21. % Executing "ldexp" runs the program \fIkarith2\fP with the -ldexp flag.
  22. %
  23. % "Data Type - Single Input" 5
  24. % .cI $DATAMANIP/repos/shared/man/sections/value_type_1input
  25. %
  26. % "Data Type - Two Input Objects" 5
  27. % .cI $DATAMANIP/repos/shared/man/sections/value_type_2input
  28. %
  29. % "Map Data - Single Input" 5
  30. % .cI $DATAMANIP/repos/shared/man/sections/map_1input
  31. %
  32. % "Map Data - Two Input Objects" 5
  33. % .cI $DATAMANIP/repos/shared/man/sections/map_2input
  34. %
  35. % "Validity Mask" 5
  36. % .cI $DATAMANIP/repos/shared/man/sections/mask_2input
  37. %
  38. % "Input Objects of Different Sizes" 5
  39. % .cI $DATAMANIP/repos/shared/man/sections/resize_2input
  40. % The values used to pad the data when input files are not the same size are
  41. % (0.0, 0.0).
  42. %
  43. % "Explicit Location and Time Data - Single Input" 5
  44. % .cI $DATAMANIP/repos/shared/man/sections/loc_and_time_1input
  45. %
  46. % "Explicit Location and Time Data - Two Input Objects" 5
  47. % .cI $DATAMANIP/repos/shared/man/sections/loc_and_time_2input
  48. %
  49. % "Failure Modes - Single Input"
  50. % .cI $DATAMANIP/repos/shared/man/sections/fail_1input
  51. %
  52. % "Failure Modes - Two Input Objects"
  53. % .cI $DATAMANIP/repos/shared/man/sections/fail_2input
  54. %
  55. %
  56. %
  57. % EXAMPLES
  58. %
  59. % "SEE ALSO"
  60. % DATAMANIP::karith2
  61. %
  62. % RESTRICTIONS
  63. % Operations on complex data are not supported at this time. If the
  64. % input object is complex, only the real component of the data is
  65. % processed, and the output object is real.
  66. %
  67. % REFERENCES
  68. %
  69. % COPYRIGHT
  70. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  71. %
  72. function varargout = kkldexp(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,..] = kkldexp(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={'i1', '__input';'o', '__output';'i2', '__input'};
  85. maxval={0,0,1};
  86. minval={0,0,1};
  87. istoggle=[0,0,1];
  88. was_set=istoggle * 0;
  89. paramtype={'InputFile','OutputFile','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 'karith2" -ldexp'],Inputs,narglist);