如何在新包中使用现有库中的现有函数数学?

问题描述

我正在开发一个具有一些简单功能的新包。现在事实证明我可以使用已经存在的“数学向量”库中的函数;特别是“插值”和“反向”。如何在我的新包中使用这些?写 y:=reverse(...) 显然是不够的,因为那样我会收到错误消息 function reverse not found in scope myTestModel。这里适用什么语法?

解决方法

正如@Priyanka 在评论中所建议的:

y:=Modelica.Math.Vectors.reverse(...);

或(另见 https://mbe.modelica.university/components/packages/importing/ ):

import Modelica.Math.Vectors.reverse; // At the start of your function/model.
...
y:=reverse(...);

对于导入,您可以选择:

import Modelica.Math.Vectors.reverse; // Just this one
import Modelica.Math.Vectors.{reverse,sort}; // More than one.

另外还有:

import Modelica.Math.Vectors.*; // All - be careful
import reverse=Modelica.Math.Vectors.sort; // Alias,DON'T!