halcon中编程运算符

Operators in a programming language are certain tokens or symbols that perform specific operations on the arguments supplied. The arguments are known as operands. These operations are usually arithmetic or logical in nature. R supports various operators across different categories.

编程语言中的运算符是对提供的参数执行特定操作的某些标记或符号。 这些参数称为操作数 。 这些操作通常本质上是算术或逻辑的。 R支持不同类别的各种运算符。

R操作员分类 (R Operators Classification)

We can classify R operators into the following categories.

我们可以将R运算符分为以下几类。

  1. Arithmetic算术
  2. Relational关系型
  3. Logical逻辑上
  4. Assignment分配
  5. Special operators特殊运营商

1. R中的算术运算符 (1. Arithmetic Operators in R)

These are the operators that perform basic arithmetic operations like addition, subtraction, multiplication, and division. In addition, there are also operators for modulus and exponentiation.

这些是执行基本算术运算(如加法,减法,乘法和除法)的运算符。 此外,还有模和幂运算符。

These operators work on both single variables and vectors. The use of these operators is straightforward.

这些运算符可用于单个变量和向量。 这些运算符的使用很简单。

The following code snippet will help you gain an understanding of these operators.

以下代码段将帮助您了解这些运算符。


#Mathemetical operations in single numeric values.
> a=2
> b=4
#Addition -- Operator +
> a+b
[1] 6
#Subtraction -- Operator -
> b-a
[1] 2
#Multiplication -- Operator *
> a*b
[1] 8
#Division -- Operator /
> b/a
[1] 2

Similarly, we also have operators for exponentiation ^ and modulo %%. These are illustrated below. The modulo operator gives the remainder of a division operation.

同样,我们也有求幂^和取模%%运算符。 这些说明如下。 模运算符给出除法运算的余数。


#Modulo Operator - %%
> x=10
> y=4
> z=x%%y
> z
[1] 2
#Exponentiation Operator - ^
> w=x^y
> w
[1] 10000

These operators also work on a vector level. Addition, subtraction and other operations work on an element by element level. This is illustrated in the code below.

这些运算符还在矢量级别上工作。 加,减和其他运算在一个元素级别上进行。 下面的代码对此进行了说明。


#Define 2 vectors
> vec1=c(2,3,5,1,4)
> vec2=c(3,4,5,1,7)
#Addition to two vectors
> vec1+vec2
[1]  5  7 10  2 11
#Subtraction of two vectors
> vec1-vec2
[1] -1 -1  0  0 -3
#Multiplication of two vectors
> vec1*vec2
[1]  6 12 25  1 28
#Division of two vectors
> vec1/vec2
[1] 0.6666667 0.7500000 1.0000000 1.0000000 0.5714286
#Exponentiation of a vector using integer
> vec1^2
[1]  4  9 25  1 16
#Element-wise exponentiation
> vec1^vec2
[1]     8    81  3125     1 16384

2. R中的关系运算符 (2. Relational Operators in R)

These are used to compare two numbers or two vectors. The main relational operators are greater than (>) , less than (<) and equal to (==).

这些用于比较两个数字或两个向量。 主要的关系运算符大于> ), 小于< )且等于== )。

There are other compound operators greater than or equal to (>=) and less than or equal to(<=). The output of these operators is a Boolean value, TRUE or FALSE. These are illustrated in the given code snippet.

还有其他大于或等于>= )且小于或等于<= )的复合运算符。 这些运算符的输出是布尔值TRUE或FALSE。 这些在给定的代码片段中进行了说明。

When applied to vectors, these operators perform an element-wise comparison and give a vector of corresponding Boolean values as a result.

当将这些运算符应用于向量时,它们将执行逐元素比较,并给出相应布尔值的向量作为结果。


> x
[1] 10
> y
[1] 4
> z
[1] 2
> w
[1] 10000
> x < w
[1] TRUE
> y > z
[1] TRUE
> x == w
[1] FALSE
> x <= x
[1] TRUE
> y >= z
[1] TRUE
> vec1<vec2 #From the previous operator set.
[1]  TRUE  TRUE FALSE FALSE  TRUE

3. R逻辑运算符 (3. R Logical Operators)

These take Boolean values as operands and give Boolean value as output. These are AND (&), OR (|) and NOT (!). These can be used as follows:

这些将布尔值作为操作数,并将布尔值作为输出。 它们是AND( & ),OR( | )和NOT( ! )。 这些可以如下使用:


#Logical AND - Gives TRUE only if both the holding conditions are TRUE.
> 2<4&4>1
[1] TRUE
> 8>8&9>8
[1] FALSE#Logical OR - Gives TRUE if any of the holding condtions are TRUE.
> (1.3-3.14<0)|(3==0)
[1] TRUE#Logical NOT - Simply negates the value from FALSE to TRUE or TRUE to FALSE.
> !(30>2)
[1] FALSE

Similar to the logical operators above, we also have element-wise logical operators – AND (&&) and OR (||). These are used upon vectors and give results corresponding to only the first elements of two vectors. This can be shown in the following code.

与上面的逻辑运算符类似,我们还有按元素的逻辑运算符– AND(&&)和OR(||)。 这些用于矢量,并给出仅与两个矢量的第一个元素相对应的结果。 可以在下面的代码中显示。


> vec1
[1] 2 3 5 1 4
> vec3
[1] 1 0 0 0 0> vec1&vec3
[1]  TRUE FALSE FALSE FALSE FALSE
> vec1&&vec3
[1] TRUE> vec1|vec3
[1] TRUE TRUE TRUE TRUE TRUE
> vec1||vec3
[1] TRUE
> !vec1
[1] FALSE FALSE FALSE FALSE FALSE

4. R赋值运算符 (4. R Assignment Operators)

The assignment operators are used to assign values to a variable. There are three assignment operators in R, left assignment (<-), right assignment (->) and equal to (=). These have been discussed in detail in the variables tutorial here.

赋值运算符用于将值赋给变量。 R中有三个赋值运算符,左赋值( <- ),右赋值( - >)等于( = )。 这些已在此处的变量教程中进行了详细讨论。

5. R中的特殊运算符 (5. Special Operators in R)

R has some operators defined for special purposes. Some of these are:

R有一些为特殊目的定义的运算符。 其中一些是:

  • Sequence Generator – Specified by a colon symbol (:)

    • Used to define a sequence range.
    • 2:10 – means a sequence from 2 to 10.

    序列发生器 –用冒号(:)指定

    • 用于定义序列范围。
    • 2:10 –表示从2到10的顺序。
  • List Indexing Operator – Specified by a dollar sign $.
    • Facilitates extracting an element of a list by its name.

    列表索引运算符 –由美元符号$指定。

    • 便于按列表名称提取列表的元素。
  • Model Formula Operator – Specified by a tilde sign ~
    • Used to define a re-usable formula along with its dependent variables.

    模型公式运算符 -由波浪号指定〜

    • 用于定义可重用公式及其因变量。

We will delve deeper into the list indexing and model formula operators in our further advanced tutorials. The sequence generator works as follows.

我们将在进一步的高级教程中深入研究列表索引和模型公式运算符。 序列发生器的工作原理如下。


> seq2 <- 2:10
> seq2
[1]  2  3  4  5  6  7  8  9 10

翻译自: https://www.journaldev.com/35056/operators-in-r-programming

halcon中编程运算符

halcon中编程运算符_R编程中的运算符相关推荐

  1. 编程中怎样将列表中数字排序_R编程中的列表

    编程中怎样将列表中数字排序 Lists in R can group together different kinds of variables into a single compound stru ...

  2. r语言barplot函数图中加标签_R语言中绘制条形图的简单方法

    原标题:R语言中绘制条形图的简单方法 条形图(bar chart)是用宽度相同的条形的高度或长短来表示数据多少的图形.它主要用来展示不同分类(横轴)下某个数值型变量(纵轴)的取值.在实际中,条形图主要 ...

  3. 2018年全国中高等院校教师“Python编程、应用及华为大数据” 、“网络空间安全”、“区块链”培训班...

    关于举办2018年全国中高等院校教师"Python编程.应用及华为大数据" ."网络空间安全"."区块链"培训班通知 全国各中高等院校计算机 ...

  4. 2018年全国中高等院校教师 “Python编程及应用”培训班通知

    山东省高教学会计算机教学研究 专业委员会文件 关于举办2018年全国中高等院校教师 "Python编程及应用"培训班通知 全国各中高等院校计算机.软件等相关院(系): Python ...

  5. 网易云课堂_C++程序设计入门(上)_第6单元:丹枫虽老犹多态–继承与多态_第6单元作业【2】- 在线编程(难度:中)...

    第6单元作业[2]- 在线编程(难度:中) 查看帮助 返回 温馨提示: 1.本次作业属于Online Judge题目,提交后由系统即时判分. 2.学生可以在作业截止时间之前不限次数提交答案,系统将取 ...

  6. android读取工程目录下的文件,Android编程实现读取工程中的txt文件功能

    本文实例讲述了Android编程实现读取工程中的txt文件功能.分享给大家供大家参考,具体如下: 1. 众所周知,Android的res文件夹是用来存储资源的,可以在res文件夹下建立一个raw文件夹 ...

  7. C 多线程编程之在类中使用多线程(thread)的方法

    一.thread的基本用法 参见C++使用thread类多线程编程 . 二.类外使用多线程,访问类的成员 这几种方式,新建线程都是在类外,然后通过把友元函数或者成员函数作为thread参数. #inc ...

  8. java链式编程_Java 中的链式编程

    前言 ​在写项目的时候,有一个实体类有好多个属性,new 出来之后需要不停的使用setXXX( )方法,效率低而且代码可读性差,查询了下发现可以实现实体类的链式编程. public class Use ...

  9. 编程求文件file1中数据的平均值,并将其与平均值最接近的数删除

    <程序设计基础-c语言>杨莉 刘鸿翔 ISBN-978-7-03-032903-5 p257 习题8 4.编程求文件file1中数据的平均值,并将其与平均值最接近的数删除 #include ...

最新文章

  1. 论文Fast and accurate short read alignment with Burrows-Wheeler transform
  2. 存储过程实现无限级分类(3)
  3. python调用大漠找图_[教程贴]按键精灵调用大漠插件后台找图示例
  4. java面试题:当一个对象被当作参数传递到一个方法后,此方法可改变这个对象的属性,并可返回变化后的结果,那么这里到底是值传递还是引用传递?
  5. 浅谈js函数三种定义方式 四种调用方式 调用顺序
  6. 学Python时需注意:单引号、双引号、三个单引号和三个双引号区别
  7. 基于JAVA+Servlet+JSP+MYSQL的旅游酒店机票预订管理系统
  8. ERP管理软件中的“七脉神剑”
  9. 手把手教你从0-1做一张酷炫驾驶舱,让老板对你赞不绝口
  10. enterprise architect绘画ER图
  11. python将数据写入txt文本文件
  12. maven setting.xml详解
  13. 明御:APT攻击预警平台
  14. 线性代数之 伪逆矩阵
  15. 【Android开发笔记】4.简单基站定位程序
  16. 大数据_数据来源类型
  17. VI的简单配置及配置文件集锦 z
  18. c语言一行黑白相间的瓷砖,磁砖样式——第八届蓝桥杯C语言B组(国赛)第二题...
  19. 地瓜叶:高纤高铁多 ,全身是宝
  20. 51cto的请看过来

热门文章

  1. 扩展 delphi 泛型 以实现类似lambda功能 , C#中的any count first last 等扩展方法
  2. [置顶] Android仿人人客户端(v5.7.1)——应用主界面之左侧面板UI实现
  3. 【备忘】一段用于在论坛上插入Flash内容的JavaScript代码
  4. 《货币战争》的一点感想
  5. [转载] python iter( )函数
  6. [转载] TensorFlow2.0 学习 线性回归
  7. IP通信基础 3.21
  8. Debian/Ubuntu Apache Mod_Rewrite 安装
  9. iframe加载完成后操作contentDocument
  10. rCNN学习笔记二:基于R-CNN的物体检测