亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

ChucK初步(3)

2019-11-14 09:02:09
字體:
來源:轉載
供稿:網友

Types, Values, and Variables(變量)

ChucK is a strongly-typed language, meaning that types are resolved(決定) at compile-time. However, it is not quite statically-typed, because the compiler/type system is a part of the ChucK virtual(虛擬的) machine, and is a runtime component(成分). This type system helps to impose(強加) PRecision(精度) and clarity(清楚) in the code, and naturally lends to organization of complex(復雜的) programs. At the same time, it is also dynamic in that changes to the type system can take place (in a well-defined(定義明確的) manner) at runtime. This dynamic(動態的) aspect(方面) forms the basis(基礎) for on-the-fly programming.

This section deals with types, values, and the declaration(聲明) and usage(使用) of variables. As in other strongly-typed programming languages, we can think of a type as associated(關聯的) behaviors(行為) of data. (For example, an ‘int’ is a type that means integer(整數), and adding two integer is defined(定義) to produce a third integer representing the sum.) Classes and objects allow us to extend(延伸) the type system with our own custom types, but we won’t cover them in this section. We will focus mainly on primitive(原始的) types here, and leave the discussion of more complex types for classes and objects.

primitive types(原始類型)

The primitive(原始的), or intrinsic(本質的) types are those which are simple datatypes (they have no additional(附加的) data attributes(屬性)). Objects are not primitive types. Primitive types are passed by value. Primitive types cannot be extended(延伸). The primitive types in ChucK are:

int : integer(整數) (signed)float : floating point number (in ChucK, a float is by default double-precision(雙精度))time : ChucKian timedur : ChucKian duration(持續)void : (no type)complex : complex number in rectangular(矩形的) form a + bi (see [below][1])polar: complex number in polar(極面) form (see [below][1])

For a summary of Operations on these types, go to operations and operators.

All other types are derived(派生) from ‘object’, either as part of the ChucK standard library, or as a new class that you create. For specification(規格), go to classes and objects.

values (literals(字面值))

Literal values are specified(指定) explicitly(明確地) in code and are assigned(分配) a type by the compiler(編譯器).The following are some examples of literal values:

int:42int (hexidecimal):0xaf30float:1.323dur:5.5::second//In the above code, second is an existing duration(持續) variable(變量). //For more on durations, see the [manipulating time(時間調節)][4] section.

variables

Variables(變量) are locations in memory that hold data. Variables have to be declared in ChucK before they are used. For example, to declare a variable of type int called foo:

// declare an 'int' called 'foo'int foo;

We can assign(分配) a value to an existing variable by using the ChucK operator (=>). This is one of the most commonly used operators in ChucK, it’s the way to do work and take action! (后面會討論)

// assign value of 2 to 'foo'2 => foo;

It is possible to combine the two statements(聲明) into one:

// assign 2 to a new variable 'foo' of type 'int'2 => int foo;

To use a variable, just refer to it by name:

// debug-print the value of foo<<< foo >>>;

To update the value of foo, for example:

// multiply 'foo' by 10, assign back to 'foo'foo * 10 => foo;

You can also do the above using a *=> (mult-chuck):

// multiply 'foo' by 10, and then assign to 'foo'10 *=> foo;

Here is an example of a duration(持續):

// assign value of '5 seconds' to new variable bar5::second => dur bar;

Once you have bar, you can inductively(歸納的) use it to construct new durations:

// 4 bar, a measure?4::bar => dur measure;

輸出: C:/Users/abc1/Desktop>chuck test.ck 882000.000000 :(dur)

Since time is central to programming ChucK, it is important to understand time, dur, the relationship and operations between them. There is more information in the manipulating time section.

reference types(引用類型)

Reference(參考) types are types which inherit(繼承) from the object class. Some default reference types include:

Object : base type that all classes inherit from (directly or indirectly)所有類繼承的基本類型array : N-dimensional ordered(有序的) set of data (of the same type)Event : fundamental(基本的), extendable(可擴展的), synchronization(同步) mechanism(機制)UGen : extendable unit generator(單元發生器) base class (U = unit, Gen = generator)string : string (of characters)

New classes can be created. All classes are reference types. We will leave the full discussion to the objects and classes section.

complex types

(虛數:直角坐標系,極坐標系)

Two special primitive types are available to to represent complex (復雜的)data, such as the output (輸出)of an FFT: complex and polar. A complex number of the form a + bi can be declared as

#(2,3) => complex cmp; //cmp is now 2 + 3i

where the #(…) syntax(語法) explicitly(明確地) denotes(表示) a complex number in rectangular form(矩形). Similarly, explicit complex numbers can be manipulated(操縱) directly:

#(5, -1.5) => complex cmp; // cmp is 5 - 1.5i#(2,3) + #(5,6) + cmp => complex sum; // sum is now 12 + 7.5i

The (floating point) real and imaginary parts(實虛部) of a complex number can be accessed(存取) with the .re and .im components of a complex number:

#(2.0,3.5) => complex cmp;cmp.re => float x; // x is 2.0cmp.im => float y; //y is 3.5

The polar type(極坐標) offers an equivalent(等價的), alternative(供選擇的) representation(表示) of complex numbers in terms of a magnitude(大小) and phase(相) value. A polar representation of a complex number can be declared as

%(2, .5*pi) => polar pol; // pol is 2∠.5π(沒有想到,竟然有這個(●'?'●))

The magnitude(大小) and phase(相) values can be accessed via .mag and .phase:

%(2, .5*pi) => polar pol;pol.mag => float m; // m is 2pol.phase => float p; //p is .5π

polar and complex representations(代表) can be cast to each other and multiplied/added/assigned(分配)/etc.:

%(2, .5*pi) => polar pol;#(3, 4) => complex cmp;pol $ complex + #(10, 3) + cmp => complex cmp2;cmp $ polar + %(10, .25*pi) - pol => polar pol2;

(這里的$實現了兩種坐標系下表示的轉換)

輸出: C:/Users/abc1/Desktop>chuck test.ck %(2.0000,0.5000*pi) :(polar) #(3.0000,4.0000) :(complex) #(13.0000,9.0000) :(complex) %(13.5540,0.2334*pi) :(polar)


上一篇:CentOS7安裝Python3.6.0

下一篇:新I/O

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩av在线不卡| 精品伊人久久97| 欧美精品激情blacked18| 国产精品视频区| 久久精品视频在线观看| 欧美日韩一区免费| 深夜福利日韩在线看| 久久噜噜噜精品国产亚洲综合| 亚洲自拍高清视频网站| 国内外成人免费激情在线视频网站| 国产精品一区二区久久| www日韩中文字幕在线看| 国产精品久久久久久网站| 成人午夜在线影院| 久久久精品国产网站| 日韩电影中文字幕一区| 色噜噜久久综合伊人一本| 国产性色av一区二区| 国产精品入口夜色视频大尺度| 久久久国产影院| 欧美激情奇米色| 欧美香蕉大胸在线视频观看| 国产日韩在线精品av| 国产精品视频26uuu| 77777亚洲午夜久久多人| 国产成人aa精品一区在线播放| 日韩av手机在线看| 国产精品久久久久久久久影视| 日韩一区二区福利| 欧美另类极品videosbestfree| 日韩欧美在线免费观看| 国产ts一区二区| 国产精品精品视频一区二区三区| 91香蕉电影院| 亚洲成年人在线播放| 亚洲国产精品久久久久| 91av视频在线播放| 欧美亚洲免费电影| 狠狠躁18三区二区一区| 国产一区二区三区毛片| 亚洲国产另类 国产精品国产免费| 欧美理论电影网| 中文字幕精品久久| 少妇av一区二区三区| 国产精品视频区| 福利精品视频在线| 欧美午夜女人视频在线| 亚洲天堂开心观看| 国产精品免费一区豆花| 国产在线播放91| 欧美午夜精品在线| 亚洲性日韩精品一区二区| 精品国产欧美一区二区三区成人| 岛国av在线不卡| 九九热最新视频//这里只有精品| 欧美区在线播放| 精品国内产的精品视频在线观看| 国产亚洲精品久久久久久牛牛| 在线精品国产欧美| www.日韩不卡电影av| 日韩在线视频导航| 久久99精品视频一区97| 国产日本欧美在线观看| 最新亚洲国产精品| 亚洲欧美成人一区二区在线电影| 大胆人体色综合| 美女视频黄免费的亚洲男人天堂| 亚洲免费伊人电影在线观看av| xxxxx成人.com| 国产精品一区二区久久国产| 亚洲成人网在线| 亚洲人线精品午夜| 国产精品网站大全| 日韩成人在线播放| 欧美精品videossex88| 视频直播国产精品| 亚洲色图第三页| 欧美视频一二三| 国产精品高潮在线| 成人看片人aa| 色一区av在线| 91极品视频在线| 国产精品久久久久久久久久免费| 久久人人看视频| 亚洲男人天堂网站| 美女视频久久黄| 国产精品久久久久久久美男| 91最新国产视频| 日韩高清免费观看| 久久久精品久久| 日韩中文理论片| 国产亚洲视频中文字幕视频| 久久九九国产精品怡红院| 日韩在线视频国产| 欧美成人自拍视频| 黄网站色欧美视频| 精品在线观看国产| 色妞在线综合亚洲欧美| 国产亚洲aⅴaaaaaa毛片| 国产精品va在线播放我和闺蜜| 欧美孕妇性xx| 国产精品视频专区| 日韩在线观看免费| 伊人久久综合97精品| 亚洲国产精品久久久| 亚洲欧美日韩直播| 狠狠久久亚洲欧美专区| 精品久久久一区| 欧美裸体xxxx极品少妇软件| 麻豆成人在线看| 国产精品久久久久久久久影视| 欧美日韩国产麻豆| 久久91亚洲精品中文字幕奶水| 国产欧美精品xxxx另类| 日本最新高清不卡中文字幕| 国产在线不卡精品| 韩剧1988免费观看全集| 国产精品444| 69影院欧美专区视频| 久久免费精品日本久久中文字幕| 日韩色av导航| 国产精品久久久久久久久久尿| 久久久久久久久久久久久久久久久久av| 日韩精品在线观看一区| 欧洲一区二区视频| 欧洲成人免费视频| 久久精品最新地址| 懂色av一区二区三区| 久久久久久伊人| 一区二区三区在线播放欧美| 美女啪啪无遮挡免费久久网站| 91久久夜色精品国产网站| 国产精选久久久久久| 久久精品国产清自在天天线| 国产日韩在线亚洲字幕中文| 欧美中文在线字幕| 国产精品嫩草视频| 亚洲精品欧美日韩专区| 日韩av电影在线播放| 欧美一区二区色| 久久国产色av| 高清欧美性猛交xxxx黑人猛交| 日韩av在线直播| 欧美亚洲国产视频小说| 日韩欧美成人区| 亚洲电影免费观看| 欧美黑人视频一区| 国产精品高潮呻吟久久av野狼| 成人妇女淫片aaaa视频| 国产精品99久久久久久久久| 国产精品天天狠天天看| 57pao成人国产永久免费| 国产精品青青在线观看爽香蕉| 亚洲自拍高清视频网站| 中文字幕日韩有码| 国产精品视频免费在线| 日韩免费av一区二区| 亚洲伊人成综合成人网| 欧美精品生活片| 亚洲成人久久一区| 亚洲精品有码在线| 日韩日本欧美亚洲| 在线播放国产一区中文字幕剧情欧美| 国产视频精品va久久久久久|