function cplusdmo(action)
% MATLAB C++ Math Library Information 

%   Yama Habibzai
%   Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
%   $Revision: 1.3 $
%   $Date: 1997/11/21 19:38:54 $

if nargin<1,
  fig = findobj('Type', 'figure', 'Name', 'C++ Math Library');
  
  if isempty(fig)
    figpos = getfgpos(560, 420);
    fig = figure('NumberTitle', 'off',...
        'Position', figpos, 'Name', 'C++ Math Library',...
        'Resize', 'off',...
        'Color', [.8 .8 .8]);
    
  end
  %----------
  labelColor=[0.8 0.8 0.8];
  yInitPos=0.90;
  top=0.95;
  bottom=0.05;
  left=0.85;
  btnWid=0.10;
  btnHt=0.10;
  %    % Spacing between the button and the next command's label
  spacing=0.04;
  %%---------------
  str1 = ' ';
  str2 = '              MATLAB C++ Math Library';
  str4 = '  With the C++ Math Library, you can incorporate';
  str6 = '  powerful MATLAB numeric routines into programs';
  str7 = '  written in C++. The MATLAB C++ Math Library is'; 
  str8 = '  designed for building standalone mathematical'; 
  str9 = '  applications that require the power of MATLAB'; 
  str10 = '  functions in a compiled C++ based environment.';
  myxp(str1, str2, str1, str4, str6, str7, str8, str9, str10);
  
  button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
  if exist('button')
    delete(button);
  end
  
  push_right = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [0.5339    0.0167    0.1250    0.0714],...
      'String', 'Next >>>',....
      'Tag', 'contbutton', 'callback', 'cplusdmo func2');
  
  push_right = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [0.3018 0.0167 0.125 0.0714],...
       'String', '<<< Back',....
      'Tag', 'contbutton', 'Enable', 'off', 'callback', ' ');
  
  push_right2 = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [ 0.8196    0.0167    0.0804    0.0714],...
      'String', 'Exit', 'callback', 'close');
  
  
else,
  switch action
  case 'func2',func2;
  case 'func3', func3;
  case 'func4', func4;
  case 'func5', func5;
  case 'func6', func6;
  case 'func7', func7;
  case 'func8', func8;
  case 'open_eval', open_eval;
  end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Local Functions %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function func2()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'FEATURES:';
st = 'A Library of math functions for:';
s2 = '- Matrix arithmetic'; 
s3=  '- Matrix comparisons  ';
s4 = '- Linear equation solving'; 
s5 = '- LU, QR, SVD, and eigenvalues';
s6 = '- Inverse, determinant, and exponential   ';
s7 = '- Elementary math  ';
s8 = '- Beta, gamma, erf, and elliptic functions';
s9=  '- Basic statistic and data analysis'; 
s10= '- Polynomial roots';
s11= '- Filter, convolution, and FFT '; 
s12= '- Interpolation';
s13= '- String operations';
s14 ='- File input/output (I/O)';
s15 = ' ';
s16 = 'Plus a  matrix object that lets you program in C++';
s17 = 'using MATLAB-style syntax.';

myxp(s1, st, s2, s3, s4, s5,s6, s7, s8, s9, s10, s11, s12,s15, s16, s17);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'cplusdmo func3');


push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'cplusdmo');

function func3()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = '                HIGHLIGHTS';
st = '          ';
sb = 'Standalone C++ Programs:';
sc = '          ';
s2 = 'To build standalone C++ programs that rely on';
s3=  'MATLAB''s core math and data analysis routines,';
s4=  'you can convert your M-files into C++ with the';
s5=  'MATLAB Compiler, or you can program directly in';
s6=  'C++ and call functions contained in the C++'; 
s7 = 'Math Library.';
myxp(s1,st, sb, sc, s2, s3, s4, s5, s6, s7);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'cplusdmo func4');


push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'cplusdmo func2');

function func4()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'Familiar MATLAB Syntax:';
s2 = '                 ';
s3 = 'The C++ Math Library offers a natural, intuitive';
s4 = 'syntax for accessing a rich collection of powerful';
s5=  'numeric functions. Because the syntax is very';
s6 = 'similar to the MATLAB language, you can build,';
s7 = 'maintain, and enhance C++ programs very quickly-';
s8 = 'and with limited C++ training.';
s9 = s2; 
s10 = 'Faster Code:';
s11 = s2;
s12 = 'Compiling an M-file into C++ code can improve the';
s13 = 'code''s performance. Speed gains of up to 20';
s14 = 'times faster are possible.';

myxp(s1,s2, s3,s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'cplusdmo func5');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'cplusdmo func3 ');


function func5()
clf;
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

s1 = 'Combined Advantages:';
ss = '                   ';
s2 = 'With the C++ Math Library, you can take advantage';
s3 = 'of the added speed of C++ and the flexible MATLAB';
s4 = 'coding style that the library supports.';
s5 = '';
s6 = 'The next slide shows the MATLAB code of an M-file';
s7 = 'function, hilb.m, and the corresponding C++ code -';
s8 = 'including C++ Math Library calls - automatically';
s9 = 'produced by the MATLAB compiler.';
s10 ='';
s11 ='';
s12= '';
s13= '';

myxp(s1,ss,s2,s3,s4,s5,s6,s7,s8, s9, s10,s11,s12,s13);

push_right2 = uicontrol('Style', 'Push',...
    'Position', [300 8 70 30], 'String', 'Next >>>',...
    'Tag', 'contbutton', 'callback', 'cplusdmo func6');

push_right = uicontrol('Style', 'Push',...
    'Position', [170 8 70 30], 'String', '<<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'cplusdmo func4');

  push_right2 = uicontrol('Style', 'Push',...
      'Units', 'Normalized',...
      'Position', [ 0.8196    0.0167    0.0804    0.0714],...
      'String', 'Exit', 'callback', 'close');


function func6()
button = findobj(gcf, 'type', 'uicontrol', 'Tag', 'contbutton');
if exist('button')
  delete(button);
end

clf;
set(gcf, 'Units', 'Normalized');
leftax=axes('Position', [.05 .2 .4 .5]);

% Now the strings in this axes
space = '    ';
sl1 = 'J = 1:n;';
sl2 = 'J = J(ones(n,1),:);';
sl3 = 'I = J'';';
sl4 = 'E = ones(n,n);';
sl5 = 'H = E./(I+J-1);';  
myxp(sl1, space, sl2, space, sl3,space,  sl4, space, sl5);

rightax = axes('Position', [.55 .2 .4 .5]);

% Now the string in the right axes
sr1 = 'mwMatrix J, I, E, H;';
sr2 = 'J = ramp(1,n);';
sr3 = 'J = J(ones(n,1), colon());';
sr4 = 'I = ctranspose(J);';
sr5 = 'E = ones(n,n);';
sr6 = 'H = rdivide(E, I+J-1);';
myxp(sr1, space, sr2, space, sr3, space, sr4, space, sr5, space, sr6);

figcolor = get(gcf, 'color');

titlstring = 'Familiar M-file-style syntax in the C++ environment';

ttlstr = uicontrol('Style', 'Text', ...
'Units', 'Normalized',...
'Position', [.058 .8 .85 .15],...
'BackGroundColor', figcolor,... 
'FontUnits', 'Points',...
'Fontsize', 18,...
'ForeGroundColor', [0 0 0],...
'string', titlstring);

lefttitlestr = 'MATLAB hilb.m M-file:';

lefttitle =  uicontrol('Style', 'Text', ...
'Units', 'Normalized',...
'Position', [.03 .705 .4 .05],...
'BackGroundColor', figcolor,... 
'FontUnits', 'Points',...
'Fontsize', 14,...
'ForeGroundColor', [0 0 0],...
'string', lefttitlestr);

righttitlestr = 'Corresponding C++ code:';

righttitle =  uicontrol('Style', 'Text', ...
'Units', 'Normalized',...
'Position', [.545 .705 .4 .05],...
'BackGroundColor', figcolor,... 
'FontUnits', 'Points',...
'Fontsize', 14,...
'ForeGroundColor', [0 0 0],...
'string', righttitlestr);

right2 = uicontrol('Style', 'Push',...
    'Position', [460 10 70 28], 'String', 'Done',...
    'Tag', 'contbutton', 'callback', 'close');
 
 
push_right = uicontrol('Style', 'Pushbutton',...
    'Position', [65 10 70 28], 'String', '<< Back',....
    'Tag', 'contbutton', 'Enable', 'on', 'callback', 'cplusdmo func5');
 

