matlab 是用java写的吗_从matlab调用java是否值得?

如果您决定用MATLAB编写实现,那么这里有一些非常好的@AndrewJanke分,这是关于MATLAB中OOP性能的绝佳答案(值得阅读整篇文章):

Mimicking a C++ or Java class in MATLAB probably won’t be optimal.

Java/C++ classes are typically built such that objects are the

smallest building blocks, as specific as you can (that is, lots of

different classes), and you compose them in arrays, collection

objects, etc, and iterate over them with loops. To make fast MATLAB

classes, turn that approach inside out. Have larger classes whose

fields are arrays, and call vectorized methods on those arrays.

The point is to arrange your code to play to the strengths of the

language – array handling, vectorized math – and avoid the weak spots.

为了回答您的问题,我引用了文档:

At MATLAB startup, part of the MATLAB virtual address space is

reserved by the Java Virtual Machine (JVM) and cannot be used for

storing MATLAB arrays.

因此它仅在启动时初始化一次.

与M文件不同,调用Java方法时也会产生开销(因为必须将MATLAB类型与Java数据类型进行编组).

现在,如果您想充分利用性能,请确保将Java方法调用为:

func(obj)

代替:

obj.func()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值