[计算几何]Matrices&Linear Systems:Tuples

来源:互联网 发布:淘宝swot分析矩阵图 编辑:程序博客网 时间:2024/06/07 20:19

Conceptually, a tuple is an ordered list of elements; however,
becausethis book is about geometry in computer graphics, we’re going
to restrict our discussions to real numbers.

概念上,tuple是有序的要素列表;在计算几何中,减小讨论范围到实数部分。

  • 本书中的符号和伪代码表示方法

本书中的符号和伪代码表示方法

Nevertheless, it should be remembered that tuples and matrices may
(conceptually) be composed of complex numbers, or any arbitrary type,
and that much of what is discussed (in terms of properties, in
particular) applies to arbitrary element types.

数组和矩阵都可能由复数组成,亦或者是任意类型,大部分的在讨论,任意类型的应用。

2.2.1 定义

Generically, we refer to a tuple of n elements as an n-tuple and use
subscript notation for it: a = (a 1 , a 2 , … , a n ).

n个元素,有各自的下标

举例

a = (6, 5, 42)b = (3.14, 3.75, 8, 15)

2.2.2 算法操作

相加(减)

Addition (and subtraction) of tuples is meaningful if each tuple has
the same number of elements and the elements represent “corresponding”
quantities.

对两个有相同的元素数量,以及每个元素代表相同的元素数量的元组成对(pairwise)相加。

#Addtiona = (6, 3, 7)b = (1, 2, 4)add =  tuple([a[i]+b[i] for i in range(len(a))])print add#(7, 5, 11)

相乘(除)

#Multiplicationscalars = 2.0#2*(6, 3, 7) = (12,6,14)#(6, 3, 7) /2 = (3, 1.5, 3.5)mul = tuple([i*scalars for i in a])div = tuple([i/scalars for i in a])print mul#(12.0, 6.0, 14.0)print div#(3.0, 1.5, 3.5)

复杂的数组操作会提及不同的数据类型,这里先不展开,放到后面适当的语境中展开。

矩阵的representation, properties&application 会成为后面章节的主题。

0 0
原创粉丝点击