#*------------------------------------------------------------------- * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. * * This LIBRARY is free software; you can distribute it and/or modify * it under the therms of the ALSOC FREE LICENSE as available at * http://www.enq.ufrgs.br/alsoc. * * EMSO Copyright (C) 2004 - 2007 ALSOC, original code * from http://www.rps.eng.br Copyright (C) 2002-2004. * All rights reserved. * * EMSO is distributed under the therms of the ALSOC LICENSE as * available at http://www.enq.ufrgs.br/alsoc. * *-------------------------------------------------------------------- * Sample file for matrix functions. *-------------------------------------------------------------------- * Author: Rodolfo Rodrigues * \$Id: Matrix_Function.mso 89 2006-12-14 20:29:34Z bicca \$ *------------------------------------------------------------------*# # # EMSO sample file of matrix functions # # -------------------------------------------------------- # Function | EMSO Built-In # -------------------------------------------------------- # Sum matrix elements | sum # product matrix elements | prod # Sum transpose matrix elements | sumt # product transpose matrix elements | prodt # transpose matrix |transp # #++++++++++++++++++++++++++++++++++++++++++++++++++++ #*--------------------------------------------------- * * Given the matrix A: * * |-2 3 1 0| * |-1 -1 0 2| * | 0 5 1 0| * *--------------------------------------------------*# FlowSheet Matrix_Function PARAMETERS M as Integer; N as Integer; A(M,N) as Real; VARIABLES Sumt_(M) as Real; Sum_(N) as Real; Prodt_(M) as Real; Prod_(N) as Real; Transp_(N,M)as Real; SET M = 3; # rows N = 4; # columns A(:,1) = [-2, -1, 0]; A(:,2) = [ 3, -1, 5]; A(:,3) = [ 1, 0, 1]; A(:,4) = [ 0, 2, 0]; EQUATIONS #*--------------------------------------------------- * * |-2 3 1 0| * sum|-1 -1 0 2| = |-3 7 2 2| * | 0 5 1 0| * *---------------------------------------------------*# "Function sum" Sum_ = sum(A); #*--------------------------------------------------- * * |-2 3 1 0| | 2| * sumt|-1 -1 0 2| = | 0| * | 0 5 1 0| | 6| * *---------------------------------------------------*# "Function sumt" Sumt_ = sumt(A); #*--------------------------------------------------- * * |-2 3 1 0| * prod|-1 -1 0 2| = | 0 -15 0 0| * | 0 5 1 0| * *---------------------------------------------------*# "Function prod" Prod_ = prod(A); #*--------------------------------------------------- * * |-2 3 1 0| | 0| * prodt|-1 -1 0 2| = | 0| * | 0 5 1 0| | 0| * *---------------------------------------------------*# "Function prod" Prodt_ = prodt(A); #*--------------------------------------------------- * * |-2 3 1 0| |-2 -1 0| * transp|-1 -1 0 2| = | 3 -1 5| * | 0 5 1 0| | 1 0 1| * | 0 2 0| * *---------------------------------------------------*# "Function transp" Transp_ = transp(A); OPTIONS Dynamic = false; end