Changeset 537
- Timestamp:
- 08/16/07 13:30:55 (16 months ago)
- Location:
- Modelica/trunk/Modelica
- Files:
-
- 14 modified
-
Electrical/Digital.mo (modified) (11 diffs)
-
Math/package.mo (modified) (92 diffs)
-
Media/IdealGases/Common/package.mo (modified) (1 diff)
-
Media/Incompressible.mo (modified) (3 diffs)
-
Media/Water/IF97_Utilities.mo (modified) (2 diffs)
-
Media/Water/package.mo (modified) (1 diff)
-
Media/package.mo (modified) (5 diffs)
-
SIunits.mo (modified) (5 diffs)
-
StateGraph.mo (modified) (1 diff)
-
Utilities/Examples.mo (modified) (6 diffs)
-
Utilities/Files.mo (modified) (13 diffs)
-
Utilities/Streams.mo (modified) (10 diffs)
-
Utilities/Strings.mo (modified) (43 diffs)
-
Utilities/Types.mo (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Modelica/trunk/Modelica/Electrical/Digital.mo
r535 r537 4 4 5 5 annotation (DocumentationClass=true, Documentation(info="<html> 6 <h 3><font color=\"#008000\" size=5>Users Guide of package Electrical.Digital</font></h3>6 <h4>Users Guide of package Electrical.Digital</h4> 7 7 <p> 8 8 Library <b>Electrical.Digital</b> is a <b>free</b> Modelica package providing … … 34 34 35 35 annotation (Documentation(info="<html> 36 <h 3><font color=\"#008000\" size=5>Overview of Library Electrical.Digital</font></h3>36 <h4>Overview of Library Electrical.Digital</h4> 37 37 <p> 38 38 In this section, an overview of the most important features … … 47 47 48 48 annotation (Documentation(info="<html> 49 <h 3><font color=\"#008000\" size=5>A first example</font></h3>49 <h4>A first example</h4> 50 50 <p> 51 51 A first example will be given here (not yet done). … … 58 58 59 59 annotation (Documentation(info="<html> 60 <h 3><font color=\"#008000\" size=5>An application example</font></h3>60 <h4>An application example</h4> 61 61 <p> 62 62 An application example will be given here (not yet done). … … 69 69 70 70 annotation (Documentation(info="<html> 71 <h 3><font color=\"#008000\" size=5>Release notes</font></h3>72 <h 3><font color=\"#008000\">Version 1.0.7, 2005-07-01</font></h3>71 <h4>Release notes</h4> 72 <h4>Version 1.0.7, 2005-07-01</h4> 73 73 <ul> 74 74 <li> xxxx</li> 75 75 </ul> 76 <h 3><font color=\"#008000\">Version 1.0.6, 2004-10-18</font></h3>76 <h4>Version 1.0.6, 2004-10-18</h4> 77 77 <ul> 78 78 <li> Missing HTML tags added (problems with mismatched pre tags fixed).</li> 79 79 <li> CVS ID string deleted.</li> 80 80 </ul> 81 <h 3><font color=\"#008000\">Version 1.0.5, 2004-10-01</font></h3>81 <h4>Version 1.0.5, 2004-10-01</h4> 82 82 <ul> 83 83 <li> Wrong identifiers x0 and Tdel in HalfAdder example fixed.</li> … … 85 85 <li> Known issue: Pulse source causes a warning in Dymola. It is recommended to use Clock source.</li> 86 86 </ul> 87 <h 3><font color=\"#008000\">Version 1.0.4, 2004-09-30</font></h3>87 <h4>Version 1.0.4, 2004-09-30</h4> 88 88 <ul> 89 89 <li> Documentation improved.</li> 90 90 </ul> 91 <h 3><font color=\"#008000\">Version 1.0.3, 2004-09-21</font></h3>91 <h4>Version 1.0.3, 2004-09-21</h4> 92 92 <ul> 93 93 <li> Table names changed from \"map\" to \"Table\".</li> … … 102 102 <li> Simple Clock source added in addition to Pulse source (for convenience reasons).</li> 103 103 </ul> 104 <h 3><font color=\"#008000\">Version 1.0.2, 2004-09-13</font></h3>104 <h4>Version 1.0.2, 2004-09-13</h4> 105 105 <ul> 106 106 <li> First prerelease for discussions at the 40th Modelica Design Meeting.</li> 107 107 </ul> 108 <h 3><font color=\"#008000\">Version 1.0.1, 2004-06-01</font></h3>108 <h4>Version 1.0.1, 2004-06-01</h4> 109 109 <ul> 110 110 <li> Packages Tables, Basic, and Gates implemented.</li> 111 111 <li> Transport and inertial delay implemented and successfully tested.</li> 112 112 </ul> 113 <h 3><font color=\"#008000\">Version 1.0.0, 2003-05-01</font></h3>113 <h4>Version 1.0.0, 2003-05-01</h4> 114 114 <ul> 115 115 <li> A first version has been implemented for case studies.</li> … … 124 124 125 125 annotation (Documentation(info="<html> 126 <h 3><font color=\"#008000\" size=5>Literature</font></h3>126 <h4>Literature</h4> 127 127 <p> 128 128 The Electrical.Digital library is based on the following references: … … 161 161 162 162 annotation (Documentation(info="<html> 163 <h 3><font color=\"#008000\" size=5>Contact</font></h3>163 <h4>Contact</h4> 164 164 <dl> 165 165 <dt><b>Main Authors:</b> … … 331 331 annotation ( 332 332 Documentation(info="<HTML> 333 <h 3><font color=\"#008000\" size=5>4 to 1 Bit Multiplexer</font></h3>333 <h4>4 to 1 Bit Multiplexer</h4> 334 334 <P> 335 335 The multiplexer converts a parallel 4 bit signal in a sequential … … 445 445 annotation ( 446 446 Documentation(info="<HTML> 447 <h 3><font color=\"#008000\" size=5>FlipFlop</font></h3>447 <h4>FlipFlop</h4> 448 448 <P> 449 449 Pulse-triggered master-slave flip-flop. -
Modelica/trunk/Modelica/Math/package.mo
r535 r537 2 2 import SI = Modelica.SIunits; 3 3 4 5 4 extends Modelica.Icons.Library2; 6 7 5 8 6 annotation(preferedView="info", … … 22 20 <p> 23 21 This package contains <b>basic mathematical functions</b> (such as sin(..)), 24 as well as functions operating on <b> matrices</b>.25 </p> 26 22 as well as functions operating on <b>vectors</b> and <b>matrices</b>. 23 </p> 24 27 25 <dl> 28 26 <dt><b>Main Author:</b> … … 35 33 email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br> 36 34 </dl> 37 35 38 36 <p> 39 37 Copyright © 1998-2007, Modelica Association and DLR. … … 59 57 Realized.</li> 60 58 </ul> 61 59 62 60 </html>")); 63 61 62 package Vectors "Library of functions operating on vectors" 63 extends Modelica.Icons.Library; 64 65 annotation ( 66 preferedView = "info", 67 Documentation(info="<HTML> 68 <h4>Library content</h4> 69 <p> 70 This library provides functions operating on vectors: 71 </p> 72 <table border=1 cellspacing=0 cellpadding=2> 73 <tr><th><i>Function</i></th> 74 <th><i>Description</i></th> 75 </tr> 76 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.isEqual\">isEqual</a>(v1, v2)</td> 77 <td>Determines whether two vectors have the same size and elements</td> 78 </tr> 79 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.norm\">norm</a>(v,p)</td> 80 <td>p-norm of vector v</td> 81 </tr> 82 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.length\">length</a>(v)</td> 83 <td>Length of vector v (= norm(v,2), but inlined and therefore usable in 84 symbolic manipulations) </td> 85 </tr> 86 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.normalize\">normalize</a>(v)</td> 87 <td>Return normalized vector such that length = 1 and prevent 88 zero-division for zero vector</td> 89 </tr> 90 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.reverse\">reverse</a>(v)</td> 91 <td>Reverse vector elements</td> 92 </tr> 93 <tr><td><a href=\"Modelica:Modelica.Math.Vectors.sort\">sort</a>(v)</td> 94 <td>Sort elements of vector in ascending or descending order</td> 95 </tr> 96 </table> 97 <h4>See also</h4> 98 <a href=\"Modelica:Modelica.Math.Matrices\">Matrices</a> 99 </HTML>")); 100 101 function isEqual "Determine if two Real vectors are numerically identical" 102 extends Modelica.Icons.Function; 103 input Real v1[:] "First vector"; 104 input Real v2[:] "Second vector (may have different length as v1"; 105 input Real eps(min=0) = 0 106 "Two elements e1 and e2 of the two vectors are identical if abs(e1-e2) <= eps"; 107 output Boolean result 108 "= true, if vectors have the same length and the same elements"; 109 110 annotation (preferedView="info", Documentation(info="<HTML> 111 <h4>Syntax</h4> 112 <blockquote><pre> 113 Vectors.<b>isEqual</b>(v1, v2); 114 Vectors.<b>isEqual</b>(v1, v2, eps=0); 115 </pre></blockquote> 116 <h4>Description</h4> 117 <p> 118 The function call \"<code>Vectors.isEqual(v1, v2)</code>\" returns <b>true</b>, 119 if the two Real vectors v1 and v2 have the same dimensions and 120 the same elements. Otherwise the function 121 returns <b>false</b>. Two elements e1 and e2 of the two vectors 122 are checked on equality by the test \"abs(e1-e2) ≤ eps\", where \"eps\" 123 can be provided as third argument of the function. Default is \"eps = 0\". 124 </p>Modelica.Utilities.Strings.isEqual 125 <h4>Example</h4> 126 <blockquote><pre> 127 Real v1[3] = {1, 2, 3}; 128 Real v2[3] = {1, 2, 3, 4}; 129 Real v3[3] = {1, 2, 3.0001}; 130 Boolean result; 131 <b>algorithm</b> 132 result := Vectors.isEqual(v1,v2); // = <b>false</b> 133 result := Vectors.isEqual(v1,v3); // = <b>false</b> 134 result := Vectors.isEqual(v1,v1); // = <b>true</b> 135 result := Vectors.isEqual(v1,v3,0.1); // = <b>true</b> 136 </pre></blockquote> 137 <h4>See also</h4> 138 <a href=\"Modelica:Modelica.Math.Matrices.isEqual\">Matrices.isEqual</a>, 139 <a href=\"Modelica:Modelica.Utilities.Strings.isEqual\">Strings.isEqual</a> 140 </HTML>")); 141 protected 142 Integer n=size(v1, 1) "Dimension of vector v1"; 143 Integer i=1; 144 algorithm 145 result := false; 146 if size(v2, 1) == n then 147 result := true; 148 while i <= n loop 149 if abs(v1[i] - v2[i]) > eps then 150 result := false; 151 i := n; 152 end if; 153 i := i + 1; 154 end while; 155 end if; 156 end isEqual; 157 158 function norm "Returns the norm of a vector" 159 extends Modelica.Icons.Function; 160 input Real v[:] "Vector"; 161 input Real p(min=1) = 2 162 "Type of p-norm (often used: 1, 2, or Modelica.Constants.inf)"; 163 output Real result "p-norm of vector v"; 164 165 annotation (preferedView="info", Documentation(info="<HTML> 166 <h4>Syntax</h4> 167 <blockquote><pre> 168 Vectors.<b>norm</b>(v); 169 Vectors.<b>norm</b>(v,p=2); // 1 ≤ p ≤ ∞ 170 </pre></blockquote> 171 <h4>Description</h4> 172 <p> 173 The function call \"<code>Vectors.<b>norm</b>(v)</code>\" returns the 174 <b>Euclidean norm</b> \"<code>sqrt(v*v)</code>\" of vector v. 175 With the optional 176 second argument \"p\", any other p-norm can be computed: 177 </p> 178 <center> 179 <IMG SRC=\"../Images/vectorNorm.png\" ALT=\"function Vectors.norm\"> 180 </center> 181 <p> 182 Besides the Euclidean norm (p=2), also the 1-norm and the 183 infinity-norm are sometimes used: 184 </p> 185 <table border=1 cellspacing=0 cellpadding=2> 186 <tr><td><b>1-norm</b></td> 187 <td>= sum(abs(v))</td> 188 <td><b>norm</b>(v,1)</td> 189 </tr> 190 <tr><td><b>2-norm</b></td> 191 <td>= sqrt(v*v)</td> 192 <td><b>norm</b>(v) or <b>norm</b>(v,2)</td> 193 </tr> 194 <tr><td><b>infinity-norm</b></td> 195 <td>= max(abs(v))</td> 196 <td><b>norm</b>(v,Modelica.Constants.<b>inf</b>)</td> 197 </tr> 198 </table> 199 <p> 200 Note, for any vector norm the following inequality holds: 201 </p> 202 <blockquote><pre> 203 <b>norm</b>(v1+v2,p) ≤ <b>norm</b>(v1,p) + <b>norm</b>(v2,p) 204 </pre></blockquote> 205 <h4>Example</h4> 206 <blockquote><pre> 207 v = {2, -4, -2, -1}; 208 <b>norm</b>(v,1); // = 9 209 <b>norm</b>(v,2); // = 5 210 <b>norm</b>(v); // = 5 211 <b>norm</b>(v,10.5); // = 4.00052597412635 212 <b>norm</b>(v,Modelica.Constants.inf); // = 4 213 </pre></blockquote> 214 <h4>See also</h4> 215 <a href=\"Modelica:Modelica.Math.Matrices.norm\">Matrices.norm</a> 216 </HTML>")); 217 algorithm 218 if p == 2 then 219 result:=sqrt(v*v); 220 elseif p == Modelica.Constants.inf then 221 result:=max(abs(v)); 222 elseif p == 1 then 223 result:=sum(abs(v)); 224 else 225 result:=(sum(abs(v[i])^p for i in 1:size(v, 1)))^(1/p); 226 end if; 227 end norm; 228 229 function length "Return length of a vector" 230 extends Modelica.Icons.Function; 231 input Real v[:] "Vector"; 232 output Real result "Length of vector v"; 233 234 annotation (preferedView="info", Documentation(info="<html> 235 <h4>Syntax</h4> 236 <blockquote><pre> 237 Vectors.<b>length</b>(v); 238 </pre></blockquote> 239 <h4>Description</h4> 240 <p> 241 The function call \"<code>Vectors.<b>length</b>(v)</code>\" returns the 242 <b>Euclidean length</b> \"<code>sqrt(v*v)</code>\" of vector v. 243 The function call is equivalent to Vectors.norm(v). The advantage of 244 length(v) over norm(v)\"is that function length(..) is implemented 245 in one statement and therefore the function is usually automatically 246 inlined. Further symbolic processing is therefore possible, which is 247 not the case with function norm(..). 248 </p> 249 <h4>Example</h4> 250 <blockquote><pre> 251 v = {2, -4, -2, -1}; 252 <b>length</b>(v); // = 5 253 </pre></blockquote> 254 <h4>See also</h4> 255 <a href=\"Modelica:Modelica.Math.Vectors.norm\">Vectors.norm</a> 256 </html>")); 257 algorithm 258 result := sqrt(v*v); 259 end length; 260 261 function normalize 262 "Return normalized vector such that length = 1 and prevent zero-division for zero vector" 263 extends Modelica.Icons.Function; 264 input Real v[:] "Vector"; 265 input Real eps = 100*Modelica.Constants.eps "if |v| < eps then result = v"; 266 output Real result[size(v, 1)] "Input vector v normalized to length=1"; 267 268 annotation (preferedView="info", Documentation(info="<html> 269 <h4>Syntax</h4> 270 <blockquote><pre> 271 Vectors.<b>normalize</b>(v); 272 Vectors.<b>normalize</b>(v,eps=100*Modelica.Constants.eps); 273 </pre></blockquote> 274 <h4>Description</h4> 275 <p> 276 The function call \"<code>Vectors.<b>normalize</b>(v)</code>\" returns the 277 <b>unit vector</b> \"<code>v/length(v)</code>\" of vector v. 278 If length(v) is close to zero (more precisely, if length(v) < eps), 279 v is returned in order to avoid 280 a division by zero. For many applications this is useful, because 281 often the unit vector <b>e</b> = <b>v</b>/length(<b>v</b>) is used to compute 282 a vector x*<b>e</b>, where the scalar x is in the order of length(<b>v</b>), 283 i.e., x*<b>e</b> is small, when length(<b>v</b>) is small and then 284 it is fine to replace <b>e</b> by <b>v</b> to avoid a division by zero. 285 </p> 286 <p> 287 Since the function is implemented in one statement, 288 it is usually inlined and therefore symbolic processing is 289 possible. 290 </p> 291 <h4>Example</h4> 292 <blockquote><pre> 293 <b>normalize</b>({1,2,3}); // = {0.267, 0.534, 0.802} 294 <b>normalize</b>({0,0,0}); // = {0,0,0} 295 </pre></blockquote> 296 <h4>See also</h4> 297 <a href=\"Modelica:Modelica.Math.Vectors.length\">Vectors.length</a> 298 </html>")); 299 algorithm 300 result := if length(v) >= eps then v/length(v) else v; 301 end normalize; 302 303 function reverse "Reverse vector elements (e.g. v[1] becomes last element)" 304 extends Modelica.Icons.Function; 305 input Real v[:] "Vector"; 306 output Real result[size(v, 1)] "Elements of vector v in reversed order"; 307 308 annotation (preferedView="info", Documentation(info="<html> 309 <h4>Syntax</h4> 310 <blockquote><pre> 311 Vectors.<b>reverse</b>(v); 312 </pre></blockquote> 313 <h4>Description</h4> 314 <p> 315 The function call \"<code>Vectors.<b>reverse</b>(v)</code>\" returns the 316 vector elements in reverse order. 317 </p> 318 <h4>Example</h4> 319 <blockquote><pre> 320 <b>reverse</b>({1,2,3,4}); // = {4,3,2,1} 321 </pre></blockquote> 322 </html>")); 323 algorithm 324 result := {v[end-i+1] for i in 1:size(v,1)}; 325 end reverse; 326 327 function sort "Sort elements of vector in ascending or descending order" 328 extends Modelica.Icons.Function; 329 input Real v[:] "Vector to be sorted"; 330 input Boolean ascending = true 331 "= true if ascending order, otherwise descending order"; 332 output Real sorted_v[size(v,1)] = v "Sorted vector"; 333 output Integer indices[size(v,1)] = 1:size(v,1) "sorted_v = v[indices]"; 334 335 annotation (preferedView="info",Documentation(info="<HTML> 336 <h4>Syntax</h4> 337 <blockquote><pre> 338 sorted_v = Vectors.<b>sort</b>(v); 339 (sorted_v, indices) = Vectors.<b>sort</b>(v, ascending=true); 340 </pre></blockquote> 341 <h4>Description</h4> 342 <p> 343 Function <b>sort</b>(..) sorts a Real vector v 344 in ascending order and returns the result in sorted_v. 345 If the optional argument \"ascending\" is <b>false</b>, the vector 346 is sorted in descending order. In the optional second 347 output argument the indices of the sorted vector with respect 348 to the original vector are given, such that sorted_v = v[indices]. 349 </p> 350 <h4>Example</h4> 351 <blockquote><pre> 352 (v2, i2) := Vectors.sort({-1, 8, 3, 6, 2}); 353 -> v2 = {-1, 2, 3, 6, 8} 354 i2 = {1, 5, 3, 4, 2} 355 </pre></blockquote> 356 </HTML>")); 357 /* shellsort algorithm; should be improved later */ 358 protected 359 Integer gap; 360 Integer i; 361 Integer j; 362 Real wv; 363 Integer wi; 364 Integer nv = size(v,1); 365 Boolean swap; 366 algorithm 367 gap := div(nv,2); 368 369 while gap > 0 loop 370 i := gap; 371 while i < nv loop 372 j := i-gap; 373 if j>=0 then 374 if ascending then 375 swap := sorted_v[j+1] > sorted_v[j + gap + 1]; 376 else 377 swap := sorted_v[j+1] < sorted_v[j + gap + 1]; 378 end if; 379 else 380 swap := false; 381 end if; 382 383 while swap loop 384 wv := sorted_v[j+1]; 385 wi := indices[j+1]; 386 sorted_v[j+1] := sorted_v[j+gap+1]; 387 sorted_v[j+gap+1] := wv; 388 indices[j+1] := indices[j+gap+1]; 389 indices[j+gap+1] := wi; 390 j := j - gap; 391 if j >= 0 then 392 if ascending then 393 swap := sorted_v[j+1] > sorted_v[j + gap + 1]; 394 else 395 swap := sorted_v[j+1] < sorted_v[j + gap + 1]; 396 end if; 397 else 398 swap := false; 399 end if; 400 end while; 401 i := i + 1; 402 end while; 403 gap := div(gap,2); 404 end while; 405 end sort; 406 end Vectors; 64 407 65 package Matrices "Functions on matrices" 408 409 package Matrices "Library of functions operating on matrices" 66 410 67 411 extends Modelica.Icons.Library; … … 78 422 autolayout=1), 79 423 Documentation(info="<HTML> 80 <h 3><font color=\"#008000\">Library content</font></h3>424 <h4>Library content</h4> 81 425 <p> 82 426 This library provides functions operating on matrices: … … 86 430 <th><i>Description</i></th> 87 431 </tr> 432 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.isEqual\">isEqual</a>(M1, M2)</td> 433 <td>Determines whether two matrices have the same size and elements</td> 434 </tr> 88 435 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.norm\">norm</a>(A)</td> 89 436 <td>1-, 2- and infinity-norm of matrix A</td> 90 437 </tr> 91 <tr><td><a href=\"Modelica:Modelica.Math.Matrices. isEqual\">isEqual</a>(M1, M2)</td>92 <td> determines whether two matrices have the same size and elements</td>438 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.sort\">sort</a>(M)</td> 439 <td>Sort rows or columns of matrix in ascending or descending order</td> 93 440 </tr> 94 441 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.solve\">solve</a>(A,b)</td> 95 442 <td>Solve real system of linear equations A*x=b with a b vector</td> 443 </tr> 444 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.solve2\">solve2</a>(A,B)</td> 445 <td>Solve real system of linear equations A*X=B with a B matrix</td> 96 446 </tr> 97 447 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.leastSquares\">leastSquares</a>(A,b)</td> … … 110 460 b vector and an LU decomposition from \"LU(..)\"</td> 111 461 </tr> 462 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.LU_solve2\">LU_solve2</a>(LU,p,B)</td> 463 <td>Solve real system of linear equations P*L*U*X=B with a<br> 464 B matrix and an LU decomposition from \"LU(..)\"</td> 465 </tr> 112 466 <tr><td>(Q,R,p) = <a href=\"Modelica:Modelica.Math.Matrices.QR\">QR</a>(A)</td> 113 467 <td> QR decomposition with column pivoting of rectangular matrix (Q*R = A[:,p]) </td> … … 115 469 <tr><td>eval = <a href=\"Modelica:Modelica.Math.Matrices.eigenValues\">eigenValues</a>(A)<br> 116 470 (eval,evec) = <a href=\"Modelica:Modelica.Math.Matrices.eigenValues\">eigenValues</a>(A)</td> 117 <td> compute eigenvalues and optionally eigenvectors<br>471 <td> Compute eigenvalues and optionally eigenvectors<br> 118 472 for a real, nonsymmetric matrix </td> 119 473 </tr> 120 474 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.eigenValueMatrix\">eigenValueMatrix</a>(eigen)</td> 121 <td> return real valued block diagonal matrix J of eigenvalues of475 <td> Return real valued block diagonal matrix J of eigenvalues of 122 476 matrix A (A=V*J*Vinv) </td> 123 477 </tr> 124 478 <tr><td>sigma = <a href=\"Modelica:Modelica.Math.Matrices.singularValues\">singularValues</a>(A)<br> 125 479 (sigma,U,VT) = <a href=\"Modelica:Modelica.Math.Matrices.singularValues\">singularValues</a>(A)</td> 126 <td> compute singular values and optionally left and right singular vectors </td>480 <td> Compute singular values and optionally left and right singular vectors </td> 127 481 </tr> 128 482 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.det\">det</a>(A)</td> 129 <td> determinant of a matrix (do <b>not</b> use; use rank(..))</td>483 <td> Determinant of a matrix (do <b>not</b> use; use rank(..))</td> 130 484 </tr> 131 485 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.inv\">inv</a>(A)</td> 132 <td> inverse of a matrix </td>486 <td> Inverse of a matrix </td> 133 487 </tr> 134 488 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.rank\">rank</a>(A)</td> 135 <td> rank of a matrix </td>489 <td> Rank of a matrix </td> 136 490 </tr> 137 491 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.balance\">balance</a>(A)</td> 138 <td> balance a square matrix to improve the condition</td>492 <td>Balance a square matrix to improve the condition</td> 139 493 </tr> 140 494 <tr><td><a href=\"Modelica:Modelica.Math.Matrices.exp\">exp</a>(A)</td> 141 <td> compute the exponential of a matrix by adaptive Taylor series<br>495 <td> Compute the exponential of a matrix by adaptive Taylor series<br> 142 496 expansion with scaling and balancing</td> 143 497 </tr> 144 498 <tr><td>(P, G) = <a href=\"Modelica:Modelica.Math.Matrices.integralExp\">integralExp</a>(A,B)</td> 145 <td> compute the exponential of a matrix and its integral</td>499 <td> Compute the exponential of a matrix and its integral</td> 146 500 </tr> 147 501 <tr><td>(P, G, GT) = <a href=\"Modelica:Modelica.Math.Matrices.integralExpT\">integralExpT</a>(A,B)</td> 148 <td> compute the exponential of a matrix and two integrals</td>502 <td> Compute the exponential of a matrix and two integrals</td> 149 503 </tr> 150 504 </table> 151 505 152 506 <p> 153 507 Most functions are solely an interface to the external LAPACK library … … 155 509 The details of this library are described in: 156 510 </p> 157 511 158 512 <dl> 159 513 <dt>Anderson E., Bai Z., Bischof C., Blackford S., Demmel J., Dongarra J., … … 162 516 Third Edition, SIAM, 1999.</dd> 163 517 </dl> 164 165 518 519 166 520 </HTML> 167 521 ")); 168 169 function norm "Returns the norm of a matrix"170 extends Modelica.Icons.Function;171 input Real A[:, :] "Input matrix";172 input Real p(min=1) = 2173 "Type of p-norm (only allowed: 1, 2 or Modelica.Constants.inf)";174 output Real result=0.0 "p-norm of matrix A";175 176 annotation (preferedView="info", Documentation(info="<HTML>177 <h3><font color=\"#008000\">Syntax</font></h3>178 <blockquote><pre>179 Matrices.<b>norm</b>(A);180 Matrices.<b>norm</b>(A, p=2);181 </pre></blockquote>182 <h3><font color=\"#008000\">Description</font></h3>183 <p>184 The function call \"<code>Matrices.norm(A)</code>\" returns the185 2-norm of matrix A, i.e., the largest singular value of A.<br>186 The function call \"<code>Matrices.norm(A, p)</code>\" returns the187 p-norm of matrix A. The only allowed values for p are</p>188 <ul>189 <li> \"p=1\": the largest column sum of A</li>190 <li> \"p=2\": the largest singular value of A</li>191 <li> \"p=Modelica.Constants.inf\": the largest row sum of A</li>192 </ul>193 <p>194 Note, for any matrices A1, A2 the following inequality holds:195 </p>196 <blockquote><pre>197 Matrices.<b>norm</b>(A1+A2,p) ≤ Matrices.<b>norm</b>(A1,p) + Matrices.<b>norm</b>(A2,p)198 </pre></blockquote>199 <p>200 Note, for any matrix A and vector v the following inequality holds:201 </p>202 <blockquote><pre>203 Vectors.<b>norm</b>(A*v,p) ≤ Matrices.<b>norm</b>(A,p)*Vectors.<b>norm</b>(A,p)204 </pre></blockquote>205 </HTML>"));206 algorithm207 if p == 1 then208 // column sum norm209 for i in 1:size(A, 2) loop210 result := max(result, sum(abs(A[:, i])));211 end for;212 elseif p == 2 then213 // largest singular value214 result := max(singularValues(A));
