function RETURN=cmult(matrix,user)
global undo; %this allows for undoing of previous command if global undo is declared in calling environment.

global noprint
global err

if(exist('matrix')==0) %check if passed matrix is defined
 noprint=1;
sprintf('%s\n','The matrix you have passed as an argument to ROWOP has not been defined.')
error(' ')
end


undo=matrix;
sizecheck=size(matrix);

brackets=findstr(user, '(' ); %check for bracket
m=findstr(user,'/');      %check for fractional multiplier

check_for_r=findstr(user,'r');
if (isempty(check_for_r)==0)
sprintf('%s','When using CMULT you must use [c] in the command line instead of [r] (which you use with the function RMULT).')

error('  ')
end

if (isempty(m)==1)    % case there is no division operator in string
    if (isempty(brackets)==1) %case no brackets no division operator
        nobracknodiv=sscanf(user,' c%d = %f c%d'); 
        operand=nobracknodiv(3,1);
      	multiplier=nobracknodiv(2,1);
	check=nobracknodiv(1,1);
   else     %case have brackets but no division operator
	bracknodiv=sscanf(user,' c%d = ( %f ) c%d'); 
	operand=bracknodiv(3,1);
        multiplier=bracknodiv(2,1);
	check=bracknodiv(1,1);
   end

else  % case there is a division operator: scan string accordingly
   if (isempty(brackets)==1) %case no brackets and have division operator
       b=sscanf(user,' c%d = %f / %f c%d'); 
       operand=b(4,1);
       multiplier=b(2,1)/b(3,1);
       check=b(1,1);
   else  %case have brackets and have division operator
	brackplusdiv=sscanf(user,' c%d = ( %f / %f) c%d'); 
	operand=brackplusdiv(4,1);
        multiplier=brackplusdiv(2,1)/brackplusdiv(3,1);
	check=brackplusdiv(1,1);
   end

end

mistake_true=0;
% sizechecking
if(operand>sizecheck(1,2))
  sprintf('%s\n%s','Error: The index number of the column you attempted to multiply','exceeds the number of columns in the matrix (on the right hand side of your expression)')
mistake_true=mistake_true+1;
err=1;
end

if(check>sizecheck(1,2))
  sprintf('%s\n%s','Error: The index number of the column you attempted to multiply','exceeds the number of columns in the matrix (on the left hand side of your expression)')
mistake_true=mistake_true+1;
err=1;
end


if(check ~=operand)
  sprintf('%s\n%s\n%s\n%s','Inconsistency: You entered an expression of the form:','cA=(k)cB','The correct expression is of the form:','cA=(k)cA')
mistake_true=mistake_true+1;
err=1;
end


if (mistake_true>0)
error('  ');
end

% execute rowop
matrix(:,operand)=multiplier*matrix(:,operand);

RETURN=matrix;





