#*------------------------------------------------------------------- * 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: * * |-1 -2 3 1 0| * | 0 -1 -1 0 2| * | 0 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 = 5; # columns N = 3; # rows A(:,1) = [-1, -2, 3, 1, 0]; A(:,2) = [ 0, -1, -1, 0, 2]; A(:,3) = [ 0, 0, 5, 1, 0]; EQUATIONS "Function sum" Sum_ = sum(A); "Function sumt" Sumt_ = sumt(A); "Function prod" Prod_ = prod(A); "Function prod" Prodt_ = prodt(A); "Function transp" Transp_ = transp(A); OPTIONS mode = "steady"; relativeAccuracy = 1e-10; end