gpt4 book ai didi

blas - 为什么加减法没有BLAS例程

转载 作者:行者123 更新时间:2023-12-04 14:39:01 28 4
gpt4 key购买 nike

在 BLAS 中有这样的例程

dscal    scale a vector by a constant  
dinit initialize a vector with given value
daxpy perform y = a*x + y

等等。但是显然没有向量加法或向量减法的例程。如果这是真的,原因是什么?

特别是因为有例程执行更琐碎的操作,例如 dinitdscal .
当然可以使用 daxpya=1a=-1从给定的向量执行加法/减法,但这在我看来过于复杂。

最佳答案

要找到合理的解释,我们必须回到 BLAS history

在那里我们可以了解到,Level 1 是在 70 年代设计的,远早于 Level 2、3(
2 级是 1987 年,3 级是 1989 年)。

关于 1 级历史,在 1979 年的论文 Basic Linear Algebra Subprograms for Fortran Usage 中由 CL Lawson 等人撰写。我们可以阅读,第 3 页

The criterion for including an operation in the package was that it should involve just one level of looping and occur in the usual algorithms of numerical linear algebra, such as Gaussian elimination or the various elimination methods using orthogonal transformations.



本文基于初始规范 1973 A Proposal for Standard Linear Algebra Subprograms汉森等人。在本文档中,您可以再次阅读:

For example, it has been found [Krogh (1)] that the use of assembly coded modules in a double precision program for solving linear equations based on Householder transfZormations with column scaling and column interchanges reduced the execution time on a Univac 1108 by 15% to 30% relative to the time required when carefully written Fortran modules were used.



之后

The operations which we feel belong in Class I according to the above stated criteria are: (1) the dot product (inner product) of two vectors, elementary vector operation, y := ax + y where x and y are n-vectors and a is a scalar, and (3) the Givens 2 x 2 orthogonal transformation applied to a 2 x n submatrix.



我们可以看到,主要关注的是使用线性替换、Givens 旋转或 Householder 变换来实现算法(线性求解器...)。在这种情况下,引用的引用文献中解释的最重要的运算是 axpy、缩放、点、范数等。目标不是提供一组完整的向量运算,如加法、减法等……而只是集中努力完成一小组程序。

关于blas - 为什么加减法没有BLAS例程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48666508/

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