向量余弦值python_向量/矩阵的余弦值打印(元素明智的操作) 使用Python的线性代数

向量余弦值python

Prerequisite:

先决条件:

Numpy is the library of function that helps to construct or manipulate matrices and vectors. The function numpy.cos(x) is a function used for generating a matrix/vector/variable with the cosine value of b x (as cos(x)). This is an element wise operation where each element in numpy.cos(x) corresponds to the Cosine of that element in x.

Numpy是一个功能库,可帮助构造或操纵矩阵和向量。 函数numpy.cos(x)是用于生成余弦值为bx的矩阵/向量/变量(作为cos(x) )的函数 。 这是一个元素明智的操作,其中numpy.cos(x)中的每个元素对应于x中该元素的余弦。

Syntax:

句法:

    numpy.cos(x)

Input parameter(s):

输入参数:

  • x – could be a matrix or vector or a variable.

    x –可以是矩阵,向量或变量。

Return value:

返回值:

A Matrix or vector or a variable of the same dimensions as input x with cos(x) values (between -1 and 1) at each entry.

与输入x尺寸相同的矩阵或向量或变量,在每个条目处具有cos(x)值(介于-1和1之间)。

Applications:

应用范围:

  1. Machine Learning

    机器学习

  2. Neural Network

    神经网络

  3. Geometry

    几何

  4. Physics Problems

    物理问题

Python代码打印向量/矩阵元素的余弦值 (Python code to print cosine value of vector/matrix elements)

# Linear Algebra Learning Sequence
# Element Wise Cosine operation

import numpy as np

# Use of np.array() to define an Vector
V = np.array([323,.623,823])
print("The Vector A : ",V)

VV = np.array([[3,63,.78],[.315,32,42]])
print("\nThe Vector B : \n",VV)

print("\ncos(A) : ", np.cos(V))
print("\ncos(B) : \n", np.cos(VV))

Output:

输出:

The Vector A :  [3.23e+02 6.23e-01 8.23e+02]

The Vector B : 
 [[ 3.    63.     0.78 ]
 [ 0.315 32.    42.   ]]

cos(A) :  [-0.83423998  0.81213169  0.99527249]

cos(B) : 
 [[-0.9899925   0.98589658  0.71091354]
 [ 0.95079638  0.83422336 -0.39998531]]


翻译自: https://www.includehelp.com/python/printing-cosine-value-of-vector-matrix-element-wise-operation.aspx

向量余弦值python

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值