[182] | 1 | #*------------------------------------------------------------------- |
---|
| 2 | * EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC. |
---|
| 3 | * |
---|
| 4 | * This LIBRARY is free software; you can distribute it and/or modify |
---|
| 5 | * it under the therms of the ALSOC FREE LICENSE as available at |
---|
| 6 | * http://www.enq.ufrgs.br/alsoc. |
---|
| 7 | * |
---|
| 8 | * EMSO Copyright (C) 2004 - 2007 ALSOC, original code |
---|
| 9 | * from http://www.rps.eng.br Copyright (C) 2002-2004. |
---|
| 10 | * All rights reserved. |
---|
| 11 | * |
---|
| 12 | * EMSO is distributed under the therms of the ALSOC LICENSE as |
---|
| 13 | * available at http://www.enq.ufrgs.br/alsoc. |
---|
| 14 | * |
---|
| 15 | *-------------------------------------------------------------------- |
---|
| 16 | * Sample file for matrix functions. |
---|
| 17 | *-------------------------------------------------------------------- |
---|
| 18 | * Author: Rodolfo Rodrigues |
---|
| 19 | * $Id: Matrix_Function.mso 89 2006-12-14 20:29:34Z bicca $ |
---|
| 20 | *--------------------------------------------------------------------*# |
---|
| 21 | # |
---|
| 22 | # EMSO sample file of matrix functions |
---|
| 23 | # |
---|
| 24 | # -------------------------------------------------------- |
---|
| 25 | # Function | EMSO Built-In |
---|
| 26 | # -------------------------------------------------------- |
---|
| 27 | # Sum matrix elements | sum |
---|
| 28 | # product matrix elements | prod |
---|
| 29 | # Sum transpose matrix elements | sumt |
---|
| 30 | # product transpose matrix elements | prodt |
---|
| 31 | # transpose matrix |transp |
---|
| 32 | # |
---|
| 33 | #++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
| 34 | |
---|
| 35 | #*--------------------------------------------------- |
---|
| 36 | * |
---|
| 37 | * Given the matrix A: |
---|
| 38 | * |
---|
| 39 | * |-1 -2 3 1 0| |
---|
| 40 | * | 0 -1 -1 0 2| |
---|
| 41 | * | 0 0 5 1 0| |
---|
| 42 | * |
---|
| 43 | *--------------------------------------------------*# |
---|
| 44 | |
---|
| 45 | FlowSheet Matrix_Function |
---|
| 46 | PARAMETERS |
---|
| 47 | M as Integer; |
---|
| 48 | N as Integer; |
---|
| 49 | A(M,N) as Real; |
---|
| 50 | |
---|
| 51 | VARIABLES |
---|
| 52 | Sumt_(M) as Real; |
---|
| 53 | Sum_(N) as Real; |
---|
| 54 | |
---|
| 55 | Prodt_(M) as Real; |
---|
| 56 | Prod_(N) as Real; |
---|
| 57 | |
---|
| 58 | Transp_(N,M)as Real; |
---|
| 59 | |
---|
| 60 | SET |
---|
| 61 | M = 5; # columns |
---|
| 62 | N = 3; # rows |
---|
| 63 | |
---|
| 64 | A(:,1) = [-1, -2, 3, 1, 0]; |
---|
| 65 | A(:,2) = [ 0, -1, -1, 0, 2]; |
---|
| 66 | A(:,3) = [ 0, 0, 5, 1, 0]; |
---|
| 67 | |
---|
| 68 | EQUATIONS |
---|
| 69 | "Function sum" |
---|
| 70 | Sum_ = sum(A); |
---|
| 71 | |
---|
| 72 | "Function sumt" |
---|
| 73 | Sumt_ = sumt(A); |
---|
| 74 | |
---|
| 75 | "Function prod" |
---|
| 76 | Prod_ = prod(A); |
---|
| 77 | |
---|
| 78 | "Function prod" |
---|
| 79 | Prodt_ = prodt(A); |
---|
| 80 | |
---|
| 81 | "Function transp" |
---|
| 82 | Transp_ = transp(A); |
---|
| 83 | |
---|
| 84 | OPTIONS |
---|
| 85 | Dynamic = false; |
---|
| 86 | end |
---|