gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 03:37:05 28 4
gpt4 key购买 nike

我正在开发一个具有一些简单功能的新包。现在我可以使用已经存在的“math-vectors”库中的函数;特别是“插值”和“反转”。如何在我的新包中使用这些?编写 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!

关于libraries - 如何在新包中使用现有库中的现有函数(数学)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66675000/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com