如何在Juila中逐元素执行exp()操作? [英] How does one perform the exp() operation element-wise in Juila?

查看:68
本文介绍了如何在Juila中逐元素执行exp()操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Julia的新手,这似乎很简单,但是由于某种原因,我在任何地方都找不到答案.

I'm new to Julia and this seems like a straight-forward operation but for some reason I am not finding the answer anywhere.

我已经在线浏览了一些教程,他们只是使用exp(A),其中A是一个nxm矩阵,但这给了我DimensionMismatch错误.

I have been going through some tutorials online and they simply use exp(A) where A is a nxm matrix but this gives me a DimensionMismatch error.

我浏览了基本函数以及线性代数部分,并对其进行了多次Google搜索,但终生无法找到它.

I looked through the documentation on the official website in the elementary functions as well as the linear algebra section and googled it multiple times but can't find it for the life of me.

推荐答案

在julia中,对矩阵的运算将矩阵视为对象,而不是数字的集合.因此,exp(A)尝试执行仅为平方矩阵定义的矩阵指数.要对矩阵进行逐元素运算,请使用通过点运算符完成的广播.因此,在这里,您需要exp.(A).

In julia, operations on matrices treat the matrix as an object rather than a collection of numbers. As such exp(A) tries to perform the matrix exponential which is only defined for square matrices. To get element-wise operations on matrices, you use broadcasting which is done with the dot operator. Thus here, you want exp.(A).

之所以使用此设计,是因为它允许对数组执行任何标量运算 而不只是语言中内置的语言.

This design is used because it allows any scalar operation to be done on arrays rather than just the ones built in to the language.

这篇关于如何在Juila中逐元素执行exp()操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆