///<reference path="../_definitions.ts"/>
/**
* The TextField class is used to create display objects for text display and
* input. <ph outputclass="flexonly">You can use the TextField class to
* perform low-level text rendering. However, in Flex, you typically use the
* Label, Text, TextArea, and TextInput controls to process text. <ph
* outputclass="flashonly">You can give a text field an instance name in the
* Property inspector and use the methods and properties of the TextField
* class to manipulate it with ActionScript. TextField instance names are
* displayed in the Movie Explorer and in the Insert Target Path dialog box in
* the Actions panel.
*
*
To create a text field dynamically, use the TextField()
* constructor.

*
*
The methods of the TextField class let you set, select, and manipulate
* text in a dynamic or input text field that you create during authoring or
* at runtime.

*
*
ActionScript provides several ways to format your text at runtime. The
* TextFormat class lets you set character and paragraph formatting for
* TextField objects. You can apply Cascading Style Sheets(CSS) styles to
* text fields by using the TextField.styleSheet property and the
* StyleSheet class. You can use CSS to style built-in HTML tags, define new
* formatting tags, or apply styles. You can assign HTML formatted text, which
* optionally uses CSS styles, directly to a text field. HTML text that you
* assign to a text field can contain embedded media(movie clips, SWF files,
* GIF files, PNG files, and JPEG files). The text wraps around the embedded
* media in the same way that a web browser wraps text around media embedded
* in an HTML document.

*
*
Flash Player supports a subset of HTML tags that you can use to format
* text. See the list of supported HTML tags in the description of the
* htmlText property.

*
* @event change Dispatched after a control value is
* modified, unlike the
* textInput event, which is
* dispatched before the value is modified.
* Unlike the W3C DOM Event Model version of
* the change event, which
* dispatches the event only after the
* control loses focus, the ActionScript 3.0
* version of the change event
* is dispatched any time the control
* changes. For example, if a user types text
* into a text field, a change
* event is dispatched after every keystroke.
* @event link Dispatched when a user clicks a hyperlink
* in an HTML-enabled text field, where the
* URL begins with "event:". The remainder of
* the URL after "event:" is placed in the
* text property of the LINK event.
*
*
Note: The default behavior,
* adding the text to the text field, occurs
* only when Flash Player generates the
* event, which in this case happens when a
* user attempts to input text. You cannot
* put text into a text field by sending it
* textInput events.

* @event scroll Dispatched by a TextField object
* after the user scrolls.
* @event textInput Flash Player dispatches the
* textInput event when a user
* enters one or more characters of text.
* Various text input methods can generate
* this event, including standard keyboards,
* input method editors(IMEs), voice or
* speech recognition systems, and even the
* act of pasting plain text with no
* formatting or style information.
* @event textInteractionModeChange Flash Player dispatches the
* textInteractionModeChange
* event when a user changes the interaction
* mode of a text field. for example on
* Android, one can toggle from NORMAL mode
* to SELECTION mode using context menu
* options
*/
module away.entities
{
export class TextField extends away.base.DisplayObject
{
private _bottomScrollV:number;
private _caretIndex:number;
private _length:number;
private _maxScrollH:number;
private _maxScrollV:number;
private _numLines:number;
private _selectionBeginIndex:number;
private _selectionEndIndex:number;
private _text:string = "";
private _textHeight:number;
private _textInteractionMode:away.text.TextInteractionMode;
private _textWidth:number;
private _charBoundaries:away.geom.Rectangle;
private _charIndexAtPoint:number;
private _firstCharInParagraph:number;
private _imageReference:away.base.DisplayObject
private _lineIndexAtPoint:number;
private _lineIndexOfChar:number;
private _lineLength:number;
private _lineMetrics:away.text.TextLineMetrics;
private _lineOffset:number;
private _lineText:string;
private _paragraphLength:number;
private _textFormat:away.text.TextFormat;
/**
* When set to true and the text field is not in focus, Flash
* Player highlights the selection in the text field in gray. When set to
* false and the text field is not in focus, Flash Player does
* not highlight the selection in the text field.
*
* @default false
*/
public alwaysShowSelection:boolean
/**
* The type of anti-aliasing used for this text field. Use
* flash.text.AntiAliasType constants for this property. You can
* control this setting only if the font is embedded(with the
* embedFonts property set to true). The default
* setting is flash.text.AntiAliasType.NORMAL.
*
*
To set values for this property, use the following string values:

*/
public antiAliasType:away.text.AntiAliasType;
/**
* Controls automatic sizing and alignment of text fields. Acceptable values
* for the TextFieldAutoSize constants:
* TextFieldAutoSize.NONE(the default),
* TextFieldAutoSize.LEFT, TextFieldAutoSize.RIGHT,
* and TextFieldAutoSize.CENTER.
*
*
If autoSize is set to TextFieldAutoSize.NONE
* (the default) no resizing occurs.

*
*
If autoSize is set to TextFieldAutoSize.LEFT,
* the text is treated as left-justified text, meaning that the left margin
* of the text field remains fixed and any resizing of a single line of the
* text field is on the right margin. If the text includes a line break(for
* example, "\n" or "\r"), the bottom is also
* resized to fit the next line of text. If wordWrap is also set
* to true, only the bottom of the text field is resized and the
* right side remains fixed.

*
*
If autoSize is set to
* TextFieldAutoSize.RIGHT, the text is treated as
* right-justified text, meaning that the right margin of the text field
* remains fixed and any resizing of a single line of the text field is on
* the left margin. If the text includes a line break(for example,
* "\n" or "\r"), the bottom is also resized to fit the next
* line of text. If wordWrap is also set to true,
* only the bottom of the text field is resized and the left side remains
* fixed.

*
*
If autoSize is set to
* TextFieldAutoSize.CENTER, the text is treated as
* center-justified text, meaning that any resizing of a single line of the
* text field is equally distributed to both the right and left margins. If
* the text includes a line break(for example, "\n" or
* "\r"), the bottom is also resized to fit the next line of
* text. If wordWrap is also set to true, only the
* bottom of the text field is resized and the left and right sides remain
* fixed.

*
* @throws ArgumentError The autoSize specified is not a member
* of flash.text.TextFieldAutoSize.
*/
public autoSize:away.text.TextFieldAutoSize;
/**
* Specifies whether the text field has a background fill. If
* true, the text field has a background fill. If
* false, the text field has no background fill. Use the
* backgroundColor property to set the background color of a
* text field.
*
* @default false
*/
public background:boolean;
/**
* The color of the text field background. The default value is
* 0xFFFFFF(white). This property can be retrieved or set, even
* if there currently is no background, but the color is visible only if the
* text field has the background property set to
* true.
*/
public backgroundColor:number /*int*/;
/**
* Specifies whether the text field has a border. If true, the
* text field has a border. If false, the text field has no
* border. Use the borderColor property to set the border color.
*
* @default false
*/
public border:boolean;
/**
* The color of the text field border. The default value is
* 0x000000(black). This property can be retrieved or set, even
* if there currently is no border, but the color is visible only if the text
* field has the border property set to true.
*/
public borderColor:number /*int*/;
/**
* An integer(1-based index) that indicates the bottommost line that is
* currently visible in the specified text field. Think of the text field as
* a window onto a block of text. The scrollV property is the
* 1-based index of the topmost visible line in the window.
*
*
All the text between the lines indicated by scrollV and
* bottomScrollV is currently visible in the text field.

*/
public get bottomScrollV():number /*int*/
{
return this._bottomScrollV;
}
/**
* The index of the insertion point(caret) position. If no insertion point
* is displayed, the value is the position the insertion point would be if
* you restored focus to the field(typically where the insertion point last
* was, or 0 if the field has not had focus).
*
*
Selection span indexes are zero-based(for example, the first position
* is 0, the second position is 1, and so on).

*/
public get caretIndex():number /*int*/
{
return this._caretIndex;
}
/**
* A Boolean value that specifies whether extra white space(spaces, line
* breaks, and so on) in a text field with HTML text is removed. The default
* value is false. The condenseWhite property only
* affects text set with the htmlText property, not the
* text property. If you set text with the text
* property, condenseWhite is ignored.
*
*
If condenseWhite is set to true, use standard
* HTML commands such as
 and
 to place line
* breaks in the text field.

*
*
Set the condenseWhite property before setting the
* htmlText property.

*/
public condenseWhite:boolean;
/**
* Specifies the format applied to newly inserted text, such as text entered
* by a user or text inserted with the replaceSelectedText()
* method.
*
*
Note: When selecting characters to be replaced with
* setSelection() and replaceSelectedText(), the
* defaultTextFormat will be applied only if the text has been
* selected up to and including the last character. Here is an example:

*
 public my_txt:TextField new TextField();
* my_txt.text = "Flash Macintosh version"; public my_fmt:TextFormat = new
* TextFormat(); my_fmt.color = 0xFF0000; my_txt.defaultTextFormat = my_fmt;
* my_txt.setSelection(6,15); // partial text selected - defaultTextFormat
* not applied my_txt.setSelection(6,23); // text selected to end -
* defaultTextFormat applied my_txt.replaceSelectedText("Windows version");
*

*
*
When you access the defaultTextFormat property, the
* returned TextFormat object has all of its properties defined. No property
* is null.

*
*
Note: You can't set this property if a style sheet is applied to
* the text field.

*
* @throws Error This method cannot be used on a text field with a style
* sheet.
*/
public defaultTextFormat:away.text.TextFormat;
/**
* Specifies whether the text field is a password text field. If the value of
* this property is true, the text field is treated as a
* password text field and hides the input characters using asterisks instead
* of the actual characters. If false, the text field is not
* treated as a password text field. When password mode is enabled, the Cut
* and Copy commands and their corresponding keyboard shortcuts will not
* function. This security mechanism prevents an unscrupulous user from using
* the shortcuts to discover a password on an unattended computer.
*
* @default false
*/
public displayAsPassword:boolean;
/**
* Specifies whether to render by using embedded font outlines. If
* false, Flash Player renders the text field by using device
* fonts.
*
*
If you set the embedFonts property to true
* for a text field, you must specify a font for that text by using the
* font property of a TextFormat object applied to the text
* field. If the specified font is not embedded in the SWF file, the text is
* not displayed.

*
* @default false
*/
public embedFonts:boolean;
/**
* The type of grid fitting used for this text field. This property applies
* only if the flash.text.AntiAliasType property of the text
* field is set to flash.text.AntiAliasType.ADVANCED.
*
*
The type of grid fitting used determines whether Flash Player forces
* strong horizontal and vertical lines to fit to a pixel or subpixel grid,
* or not at all.

*
*
For the flash.text.GridFitType property, you can use the
* following string values:

*
* @default pixel
*/
public gridFitType:away.text.GridFitType;
/**
* Contains the HTML representation of the text field contents.
*
*
Flash Player supports the following HTML tags:

*
*
Flash Player and AIR also support explicit character codes, such as
* &(ASCII ampersand) and €(Unicode € symbol).

*/
public htmlText:string;
/**
* The number of characters in a text field. A character such as tab
* (\t) counts as one character.
*/
public get length():number /*int*/
{
return this._length;
}
/**
* The maximum number of characters that the text field can contain, as
* entered by a user. A script can insert more text than
* maxChars allows; the maxChars property indicates
* only how much text a user can enter. If the value of this property is
* 0, a user can enter an unlimited amount of text.
*
* @default 0
*/
public maxChars:number /*int*/;
/**
* The maximum value of scrollH.
*/
public maxScrollH():number /*int*/
{
return this._maxScrollH;
}
/**
* The maximum value of scrollV.
*/
public maxScrollV():number /*int*/
{
return this._maxScrollV;
}
/**
* A Boolean value that indicates whether Flash Player automatically scrolls
* multiline text fields when the user clicks a text field and rolls the
* mouse wheel. By default, this value is true. This property is
* useful if you want to prevent mouse wheel scrolling of text fields, or
* implement your own text field scrolling.
*/
public mouseWheelEnabled:boolean;
/**
* Indicates whether field is a multiline text field. If the value is
* true, the text field is multiline; if the value is
* false, the text field is a single-line text field. In a field
* of type TextFieldType.INPUT, the multiline value
* determines whether the Enter key creates a new line(a value
* of false, and the Enter key is ignored). If you
* paste text into a TextField with a multiline
* value of false, newlines are stripped out of the text.
*
* @default false
*/
public multiline:boolean;
/**
* Defines the number of text lines in a multiline text field. If
* wordWrap property is set to true, the number of
* lines increases when text wraps.
*/
public get numLines():number /*int*/
{
return this._numLines;
}
/**
* Indicates the set of characters that a user can enter into the text field.
* If the value of the restrict property is null,
* you can enter any character. If the value of the restrict
* property is an empty string, you cannot enter any character. If the value
* of the restrict property is a string of characters, you can
* enter only characters in the string into the text field. The string is
* scanned from left to right. You can specify a range by using the hyphen
* (-) character. Only user interaction is restricted; a script can put any
* text into the text field. <ph outputclass="flashonly">This property does
* not synchronize with the Embed font options in the Property inspector.
*
*
If the string begins with a caret(^) character, all characters are
* initially accepted and succeeding characters in the string are excluded
* from the set of accepted characters. If the string does not begin with a
* caret(^) character, no characters are initially accepted and succeeding
* characters in the string are included in the set of accepted
* characters.

*
*
The following example allows only uppercase characters, spaces, and
* numbers to be entered into a text field:

*
 my_txt.restrict = "A-Z 0-9";

*
*
The following example includes all characters, but excludes lowercase
* letters:

*
 my_txt.restrict = "^a-z";

*
*
You can use a backslash to enter a ^ or - verbatim. The accepted
* backslash sequences are \-, \^ or \\. The backslash must be an actual
* character in the string, so when specified in ActionScript, a double
* backslash must be used. For example, the following code includes only the
* dash(-) and caret(^):

*
 my_txt.restrict = "\\-\\^";

*
*
The ^ can be used anywhere in the string to toggle between including
* characters and excluding characters. The following code includes only
* uppercase letters, but excludes the uppercase letter Q:

*
 my_txt.restrict = "A-Z^Q";

*
*
You can use the \u escape sequence to construct
* restrict strings. The following code includes only the
* characters from ASCII 32(space) to ASCII 126(tilde).

*
 my_txt.restrict = "\u0020-\u007E";

*
* @default null
*/
public restrict:string;
/**
* The current horizontal scrolling position. If the scrollH
* property is 0, the text is not horizontally scrolled. This property value
* is an integer that represents the horizontal position in pixels.
*
*
The units of horizontal scrolling are pixels, whereas the units of
* vertical scrolling are lines. Horizontal scrolling is measured in pixels
* because most fonts you typically use are proportionally spaced; that is,
* the characters can have different widths. Flash Player performs vertical
* scrolling by line because users usually want to see a complete line of
* text rather than a partial line. Even if a line uses multiple fonts, the
* height of the line adjusts to fit the largest font in use.

*
*
Note: The scrollH property is zero-based, not
* 1-based like the scrollV vertical scrolling property.

*/
public scrollH:number;
/**
* The vertical position of text in a text field. The scrollV
* property is useful for directing users to a specific paragraph in a long
* passage, or creating scrolling text fields.
*
*
The units of vertical scrolling are lines, whereas the units of
* horizontal scrolling are pixels. If the first line displayed is the first
* line in the text field, scrollV is set to 1(not 0). Horizontal scrolling
* is measured in pixels because most fonts are proportionally spaced; that
* is, the characters can have different widths. Flash performs vertical
* scrolling by line because users usually want to see a complete line of
* text rather than a partial line. Even if there are multiple fonts on a
* line, the height of the line adjusts to fit the largest font in use.

*/
public scrollV:number;
/**
* A Boolean value that indicates whether the text field is selectable. The
* value true indicates that the text is selectable. The
* selectable property controls whether a text field is
* selectable, not whether a text field is editable. A dynamic text field can
* be selectable even if it is not editable. If a dynamic text field is not
* selectable, the user cannot select its text.
*
*
If selectable is set to false, the text in
* the text field does not respond to selection commands from the mouse or
* keyboard, and the text cannot be copied with the Copy command. If
* selectable is set to true, the text in the text
* field can be selected with the mouse or keyboard, and the text can be
* copied with the Copy command. You can select text this way even if the
* text field is a dynamic text field instead of an input text field.

*
* @default true
*/
public selectable:boolean;
/**
* The zero-based character index value of the first character in the current
* selection. For example, the first character is 0, the second character is
* 1, and so on. If no text is selected, this property is the value of
* caretIndex.
*/
public get selectionBeginIndex():number /*int*/
{
return this._selectionBeginIndex;
}
/**
* The zero-based character index value of the last character in the current
* selection. For example, the first character is 0, the second character is
* 1, and so on. If no text is selected, this property is the value of
* caretIndex.
*/
public get selectionEndIndex():number /*int*/
{
return this._selectionEndIndex;
}
/**
* The sharpness of the glyph edges in this text field. This property applies
* only if the flash.text.AntiAliasType property of the text
* field is set to flash.text.AntiAliasType.ADVANCED. The range
* for sharpness is a number from -400 to 400. If you attempt to
* set sharpness to a value outside that range, Flash sets the
* property to the nearest value in the range(either -400 or 400).
*
* @default 0
*/
public sharpness:number;
/**
* Attaches a style sheet to the text field. For information on creating
* style sheets, see the StyleSheet class and the ActionScript 3.0
* Developer's Guide.
*
*
You can change the style sheet associated with a text field at any
* time. If you change the style sheet in use, the text field is redrawn with
* the new style sheet. You can set the style sheet to null or
* undefined to remove the style sheet. If the style sheet in
* use is removed, the text field is redrawn without a style sheet.

*
*
Note: If the style sheet is removed, the contents of both
* TextField.text and  TextField.htmlText change to
* incorporate the formatting previously applied by the style sheet. To
* preserve the original TextField.htmlText contents without the
* formatting, save the value in a variable before removing the style
* sheet.

*/
public styleSheet:StyleSheet;
/**
* A string that is the current text in the text field. Lines are separated
* by the carriage return character('\r', ASCII 13). This
* property contains unformatted text in the text field, without HTML tags.
*
*
To get the text in HTML form, use the htmlText
* property.

*/
public get text():string
{
return this._text;
}
public set text(value:string)
{
if (this._text == value)
return;
this._text = value;
}
/**
* The color of the text in a text field, in hexadecimal format. The
* hexadecimal color system uses six digits to represent color values. Each
* digit has 16 possible values or characters. The characters range from 0-9
* and then A-F. For example, black is 0x000000; white is
* 0xFFFFFF.
*
* @default 0(0x000000)
*/
public textColor:number /*int*/;
/**
* The height of the text in pixels.
*/
public get textHeight():number
{
return this._textHeight;
}
/**
* The interaction mode property, Default value is
* TextInteractionMode.NORMAL. On mobile platforms, the normal mode implies
* that the text can be scrolled but not selected. One can switch to the
* selectable mode through the in-built context menu on the text field. On
* Desktop, the normal mode implies that the text is in scrollable as well as
* selection mode.
*/
public get textInteractionMode():away.text.TextInteractionMode
{
return this._textInteractionMode;
}
/**
* The width of the text in pixels.
*/
public get textWidth():number
{
return this._textWidth;
}
/**
* The thickness of the glyph edges in this text field. This property applies
* only when away.text.AntiAliasType is set to
* away.text.AntiAliasType.ADVANCED.
*
*
The range for thickness is a number from -200 to 200. If
* you attempt to set thickness to a value outside that range,
* the property is set to the nearest value in the range(either -200 or
* 200).

*
* @default 0
*/
public thickness:number;
/**
* The type of the text field. Either one of the following TextFieldType
* constants: TextFieldType.DYNAMIC, which specifies a dynamic
* text field, which a user cannot edit, or TextFieldType.INPUT,
* which specifies an input text field, which a user can edit.
*
* @default dynamic
* @throws ArgumentError The type specified is not a member of
* flash.text.TextFieldType.
*/
public type:away.text.TextFieldType;
/**
* Specifies whether to copy and paste the text formatting along with the
* text. When set to true, Flash Player copies and pastes
* formatting(such as alignment, bold, and italics) when you copy and paste
* between text fields. Both the origin and destination text fields for the
* copy and paste procedure must have useRichTextClipboard set
* to true. The default value is false.
*/
public useRichTextClipboard:boolean;
/**
* A Boolean value that indicates whether the text field has word wrap. If
* the value of wordWrap is true, the text field
* has word wrap; if the value is false, the text field does not
* have word wrap. The default value is false.
*/
public wordWrap:boolean;
/**
* Creates a new TextField instance. After you create the TextField instance,
* call the addChild() or addChildAt() method of
* the parent DisplayObjectContainer object to add the TextField instance to
* the display list.
*
*
The default size for a text field is 100 x 100 pixels.

*/
constructor()
{
super();
}
/**
* Appends the string specified by the newText parameter to the
* end of the text of the text field. This method is more efficient than an
* addition assignment(+=) on a text property
* (such as someTextField.text += moreText), particularly for a
* text field that contains a significant amount of content.
*
* @param newText The string to append to the existing text.
*/
public appendText(newText:string)
{
//TODO
}
/**
* Returns a rectangle that is the bounding box of the character.
*
* @param charIndex The zero-based index value for the character(for
* example, the first position is 0, the second position is
* 1, and so on).
* @return A rectangle with x and y minimum and
* maximum values defining the bounding box of the character.
*/
public getCharBoundaries(charIndex:number):away.geom.Rectangle
{
return this._charBoundaries;
}
/**
* Returns the zero-based index value of the character at the point specified
* by the x and y parameters.
*
* @param x The x coordinate of the character.
* @param y The y coordinate of the character.
* @return The zero-based index value of the character(for example, the
* first position is 0, the second position is 1, and so on). Returns
* -1 if the point is not over any character.
*/
public getCharIndexAtPoint(x:number, y:number):number /*int*/
{
return this._charIndexAtPoint;
}
/**
* Given a character index, returns the index of the first character in the
* same paragraph.
*
* @param charIndex The zero-based index value of the character(for example,
* the first character is 0, the second character is 1, and
* so on).
* @return The zero-based index value of the first character in the same
* paragraph.
* @throws RangeError The character index specified is out of range.
*/
public getFirstCharInParagraph(charIndex:number /*int*/):number /*int*/
{
return this._firstCharInParagraph;
}
/**
* Returns a DisplayObject reference for the given id, for an
* image or SWF file that has been added to an HTML-formatted text field by
* using an  tag. The  tag is in the
* following format:
*
*

*
* @param id The id to match(in the id attribute
* of the  tag).
* @return The display object corresponding to the image or SWF file with the
* matching id attribute in the  tag
* of the text field. For media loaded from an external source, this
* object is a Loader object, and, once loaded, the media object is a
* child of that Loader object. For media embedded in the SWF file,
* it is the loaded object. If no  tag with the
* matching id exists, the method returns
* null.
*/
public getImageReference(id:string):away.base.DisplayObject
{
return this._imageReference;
}
/**
* Returns the zero-based index value of the line at the point specified by
* the x and y parameters.
*
* @param x The x coordinate of the line.
* @param y The y coordinate of the line.
* @return The zero-based index value of the line(for example, the first
* line is 0, the second line is 1, and so on). Returns -1 if the
* point is not over any line.
*/
public getLineIndexAtPoint(x:number, y:number):number /*int*/
{
return this._lineIndexAtPoint;
}
/**
* Returns the zero-based index value of the line containing the character
* specified by the charIndex parameter.
*
* @param charIndex The zero-based index value of the character(for example,
* the first character is 0, the second character is 1, and
* so on).
* @return The zero-based index value of the line.
* @throws RangeError The character index specified is out of range.
*/
public getLineIndexOfChar(charIndex:number /*int*/):number /*int*/
{
return this._lineIndexOfChar;
}
/**
* Returns the number of characters in a specific text line.
*
* @param lineIndex The line number for which you want the length.
* @return The number of characters in the line.
* @throws RangeError The line number specified is out of range.
*/
public getLineLength(lineIndex:number /*int*/):number /*int*/
{
return this._lineLength;
}
/**
* Returns metrics information about a given text line.
*
* @param lineIndex The line number for which you want metrics information.
* @return A TextLineMetrics object.
* @throws RangeError The line number specified is out of range.
*/
public getLineMetrics(lineIndex:number /*int*/):away.text.TextLineMetrics
{
return this._lineMetrics;
}
/**
* Returns the character index of the first character in the line that the
* lineIndex parameter specifies.
*
* @param lineIndex The zero-based index value of the line(for example, the
* first line is 0, the second line is 1, and so on).
* @return The zero-based index value of the first character in the line.
* @throws RangeError The line number specified is out of range.
*/
public getLineOffset(lineIndex:number /*int*/):number /*int*/
{
return this._lineOffset;
}
/**
* Returns the text of the line specified by the lineIndex
* parameter.
*
* @param lineIndex The zero-based index value of the line(for example, the
* first line is 0, the second line is 1, and so on).
* @return The text string contained in the specified line.
* @throws RangeError The line number specified is out of range.
*/
public getLineText(lineIndex:number /*int*/):string
{
return this._lineText;
}
/**
* Given a character index, returns the length of the paragraph containing
* the given character. The length is relative to the first character in the
* paragraph(as returned by getFirstCharInParagraph()), not to
* the character index passed in.
*
* @param charIndex The zero-based index value of the character(for example,
* the first character is 0, the second character is 1, and
* so on).
* @return Returns the number of characters in the paragraph.
* @throws RangeError The character index specified is out of range.
*/
public getParagraphLength(charIndex:number /*int*/):number /*int*/
{
return this._paragraphLength;
}
/**
* Returns a TextFormat object that contains formatting information for the
* range of text that the beginIndex and endIndex
* parameters specify. Only properties that are common to the entire text
* specified are set in the resulting TextFormat object. Any property that is
* mixed, meaning that it has different values at different points in
* the text, has a value of null.
*
*
If you do not specify values for these parameters, this method is
* applied to all the text in the text field.

*
*
The following table describes three possible usages:

*
* @return The TextFormat object that represents the formatting properties
* for the specified text.
* @throws RangeError The beginIndex or endIndex
* specified is out of range.
*/
public getTextFormat(beginIndex:number /*int*/ = -1, endIndex:number /*int*/ = -1):away.text.TextFormat
{
return this._textFormat;
}
/**
* Replaces the current selection with the contents of the value
* parameter. The text is inserted at the position of the current selection,
* using the current default character format and default paragraph format.
* The text is not treated as HTML.
*
*
You can use the replaceSelectedText() method to insert and
* delete text without disrupting the character and paragraph formatting of
* the rest of the text.

*
*
Note: This method does not work if a style sheet is applied to
* the text field.

*
* @param value The string to replace the currently selected text.
* @throws Error This method cannot be used on a text field with a style
* sheet.
*/
public replaceSelectedText(value:string)
{
}
/**
* Replaces the range of characters that the beginIndex and
* endIndex parameters specify with the contents of the
* newText parameter. As designed, the text from
* beginIndex to endIndex-1 is replaced.
*
*
Note: This method does not work if a style sheet is applied to
* the text field.

*
* @param beginIndex The zero-based index value for the start position of the
* replacement range.
* @param endIndex The zero-based index position of the first character
* after the desired text span.
* @param newText The text to use to replace the specified range of
* characters.
* @throws Error This method cannot be used on a text field with a style
* sheet.
*/
public replaceText(beginIndex:number /*int*/, endIndex:number /*int*/, newText:string)
{
}
/**
* Sets as selected the text designated by the index values of the first and
* last characters, which are specified with the beginIndex and
* endIndex parameters. If the two parameter values are the
* same, this method sets the insertion point, as if you set the
* caretIndex property.
*
* @param beginIndex The zero-based index value of the first character in the
* selection(for example, the first character is 0, the
* second character is 1, and so on).
* @param endIndex The zero-based index value of the last character in the
* selection.
*/
public setSelection(beginIndex:number /*int*/, endIndex:number /*int*/)
{
}
/**
* Applies the text formatting that the format parameter
* specifies to the specified text in a text field. The value of
* format must be a TextFormat object that specifies the desired
* text formatting changes. Only the non-null properties of
* format are applied to the text field. Any property of
* format that is set to null is not applied. By
* default, all of the properties of a newly created TextFormat object are
* set to null.
*
*
Note: This method does not work if a style sheet is applied to
* the text field.

*
*
The setTextFormat() method changes the text formatting
* applied to a range of characters or to the entire body of text in a text
* field. To apply the properties of format to all text in the text field, do
* not specify values for beginIndex and endIndex.
* To apply the properties of the format to a range of text, specify values
* for the beginIndex and the endIndex parameters.
* You can use the length property to determine the index
* values.

*
*
The two types of formatting information in a TextFormat object are
* character level formatting and paragraph level formatting. Each character
* in a text field can have its own character formatting settings, such as
* font name, font size, bold, and italic.

*
*
For paragraphs, the first character of the paragraph is examined for
* the paragraph formatting settings for the entire paragraph. Examples of
* paragraph formatting settings are left margin, right margin, and
* indentation.

*
*
Any text inserted manually by the user, or replaced by the
* replaceSelectedText() method, receives the default text field
* formatting for new text, and not the formatting specified for the text
* insertion point. To set the default formatting for new text, use
* defaultTextFormat.

*
* @param format A TextFormat object that contains character and paragraph
* formatting information.
* @throws Error This method cannot be used on a text field with a style
* sheet.
* @throws RangeError The beginIndex or endIndex
* specified is out of range.
*/
public setTextFormat(format:away.text.TextFormat, beginIndex:number /*int*/ = -1, endIndex:number /*int*/ = -1)
{
}
/**
* Returns true if an embedded font is available with the specified
* fontName and fontStyle where
* Font.fontType is flash.text.FontType.EMBEDDED.
* Starting with Flash Player 10, two kinds of embedded fonts can appear in a
* SWF file. Normal embedded fonts are only used with TextField objects. CFF
* embedded fonts are only used with the flash.text.engine classes. The two
* types are distinguished by the fontType property of the
* Font class, as returned by the enumerateFonts()
* function.
*
*
TextField cannot use a font of type EMBEDDED_CFF. If
* embedFonts is set to true and the only font
* available at run time with the specified name and style is of type
* EMBEDDED_CFF, Flash Player fails to render the text, as if no
* embedded font were available with the specified name and style.

*
*
If both EMBEDDED and EMBEDDED_CFF fonts are
* available with the same name and style, the EMBEDDED font is
* selected and text renders with the EMBEDDED font.

*
* @param fontName The name of the embedded font to check.
* @param fontStyle Specifies the font style to check. Use
* flash.text.FontStyle
* @return true if a compatible embedded font is available,
* otherwise false.
* @throws ArgumentError The fontStyle specified is not a member
* of flash.text.FontStyle.
*/
public static isFontCompatible(fontName:string, fontStyle:string):boolean
{
return false;
}
}
}


You can initialize the lighbox using any
elements. The first image on this page is a simple
element:

data-image-opened
attributeIf you don't want to load the full image but a small thumbnail (when the lightbox is not opened) you can set data-image-opened
attribute. It will be the path to the image that will be opened in the lightbox.
By returning false
in the hook functions, we can stop the default behavior of the library.


Solutions-driven Front-End Software Developer with 5 years experience developing front-end systems with JavaScript, JQuery, HTML5, CSS3 and JavaScript libraries such as ReactJS. Expertise in all phases of software development life cycle (SDLC), including User Experience (UX), User Interaction (UI), Business Analysis/Modeling, Design/Architecture, Development, Implementation, Integration, Documentation, Testing, and Deployment. Adept at utilizing modern web development tooling and command-line interfaces (Git) to design and develop web applications. Passionate learner with demonstrated ability to learn and grasp new concepts and emerging technologies quickly. Collaborative professional who works well with teams or independently in an Agile environment to develop full-featured interactive applications with extensive networking and media functionality. Excellent communication, analytical, interpersonal, problem solving and presentation skills. I am currently a full-time software engineering student at Springboard, projected completion date is 10.31.21. In my spare time I practice and teach Ving Tsun.
Provide tier II level support for customers using Vertex tax calculation software (O Series). O Series performs background tax calculation for online transactions
Technolgies used: O-Series, Jira, SoapUI, Tomcat, XML, Windows VM, Oracle, Salesforce, Command Line Tools
Manage resolution of complex issues to include application support, performance tuning, configuration issues, incident identification, escalations, system testing, disaster recovery, strategy sessions and training.
Technolgies used: Ionic Framework, App-Flow, Git, GitHub, Node, React, Angular, Jira, Command Line Tools
Developed highly interactive web applications utilizing JavaScript, HTML5, CSS, JSON, ReactJS and integrating Restful API’s, and external web services ensuring high performance.
Technolgies used: HTML, CSS, JavaScript, ReactJS, NodeJS, SQL
Technolgies used: HTML5, CSS3, JavaScript, Git, GitHub, Command Line ToolsL
Rutger University - Bachelor Of Arts - Philosophy
I started the South Jersey Full Stack JavaScript meetup group to create a community for people like myself who have a passion for web development technology. The group exist to facilitate learning the latest technology trends in full stack JavaScript and also to create opporntunities for networking and career advancement for its members. You can find more information about it here.


--- layout: post title: "New to town - the Galaxy S21, Galaxy S21 Plus, and the Galaxy S21 Ultra - Priced at $799 ; $999 and $1,999 respectively" subtitle: "Some of the least expensive flagship phones that Samsung has made in years" date: 2021-01-15 19:00:13 +0530 background: '/img/posts/06.jpg' published: true categories: [ Technology ] tags: [ technology, samsung, smartphone, galaxys21, flagship ] ---
Samsung’s Samsung’s latest flagships are here: the Galaxy S21, Galaxy S21 Plus, and the Galaxy S21 Ultra. The first two — which start at $799 and $999, respectively
It marks some of the least expensive flagship phones that Samsung has made in years, while the $1,199 S21 Ultra aims to be not just the top-specced phone in Samsung’s lineup, but also the best phone, period.
The new devices can effectively be divided into two categories: the S21 and S21 Plus, which are aiming to achieve a more wallet-friendly flagship experience, and the S21 Ultra, the ultimate Samsung smartphone that cuts no corners and aims to offer the most premium phone possible — with a price tag to match.
The displays, while the same 6.2-inch (S21) and 6.7-inch (S21 Plus) sizes as last year’s models, have dropped the subtly curved edges that have been a Samsung hallmark for years. Those flat panel screens also feature a step down in resolution from the 3200 x 1440 panels on last year’s models to a more modest 2400 x 1080 resolution. Both phones still offer 120Hz refresh rates, although it’s dynamically adjusted now.
Lastly, the RAM has also been dropped from 12GB to 8GB.
The smaller Galaxy S21 makes additional trade-offs: the back panel is made of polycarbonate plastic, not glass, and it lacks an ultra-wideband radio (which the S21 Plus and Ultra offer for better integration with Samsung’s new Galaxy SmartTag.)
Lastly, Samsung is following in Apple’s footsteps by no longer including a charging brick or headphones in the box, justifying it with similar environmental reasons (although Samsung will also likely save a few dollars by not bundling those parts).
It’s not all downgrades, however: the processor is Qualcomm’s latest Snapdragon 888 chipset, which promises big improvements in overall performance. There’s comprehensive 5G integration on both devices, with support for mmWave and sub-6GHz networks.
The fingerprint sensor has been upgraded to Qualcomm’s new 3D Sonic Sensor Gen 2, which should be faster and easier to use.
The batteries are still big: the S21 still offers a beefy 4,000mAh battery, and the S21 Plus has been upgraded to an even larger 4,800mAh one.
The S21 and S21 Plus still have camera bumps, but they look good as seamless pieces of metal that flow out naturally from the matching sides of the phones, with smooth edges and spiffy two-tone designs that look really nice.
Largely unchanged from last year, though, is the camera system itself. Both the S21 and S21 Plus offer a 12-megapixel wide-angle camera, a 12-megapixel ultrawide camera, and a 64-megapixel telephoto lens, along with a 10-megapixel selfie camera.


Volume_To_Contour generates contours from Volume data or 3D field data.
Input Ports
Name Type Description in Mesh+Data input volume data or 3D field
Parameters
Name Type Description UI Control Axis int The axis of contours Slider First_Slice int The position of first slice. Slider Last_Slice int The position of last slice. Slider Slice_Spacing int The gap size between two slices. Slider NContours int The number of isoline(contours) in the each slice. Slider Level_min float Minimum level of contours. Slider Level_max float Maximum level of contours. Slider Color int Monochrome or color contours. Toggle
Output Ports
Name Type Description out Mesh+Data output field of contours.
Volume_To_Contour generates a set of orthoslices and on each slice there are a set of contours. This module acutally combines two AVS modules: isoline and orthoslice. The orthoslice generates slices from 3D field data and the isoline creates the contours on each slice.
Note: This module only works for one component field data. You can use extract_component to extract a single component from data with multiple components.
in
Reference to the input field. It has to be a 3D field or volume data.
Axis
The Axis of contours. It could be 0, 1 or 2 which corresponds to X, Y or Z axis in 3D.
First_Slice
The position of first slice. The minimum value is 1 and maximum value is the dimension of the axis. This value has to be less or equal to the value of Last_Slice.
Last_Slice
The position of last slice. The minimum value is 1 and maximum value is the dimension of the axis. This value has to be greater or equal to the value of First_Slice.
Slice_Spacing
The gap size between two slices. It is a integer value.
NContours
The number of contours on each slice. It is between 1 and 20. You can modify the maximum value in the V file of UI definition if a maximum of 20 is not sufficient for your purposes.
Level_min
This float value is used to define the node data value which is used for the minimum isoline. The minimum and maximum of this value are the minimum and maximum of node data values.
Level_max
This float value is used to define the node data value which is used for the maximum isoline. The minimum and maximum of this value are the minimum and maximum of node data values.
Color
This int value is used to control if the contours are colourized. Value 0 gives monochrome isolines and 1 gives coloured isolines.
out
The output field of contours. It is a field of uniform mesh plus node data.
The User Macro Volume_To_Contour makes use of the Functional Macro VolumeToContourFunc and the UI Macro VolumeToContourUI.
An example application VolumeToContourEg is provided, which uses the AVS/Express sample data file wind.fld, to display the contours.
xp_comm_proj/vcontour/vcontmod.v contains the V definitions of the VolumeToContourParams parameter block and the VolumeToContour module.
xp_comm_proj/vcontour/vcontmac.v contains the V definitions of the VolumeToContourFunc Functional Macro, the VolumeToContourUI User Interface Macro, and the Volume_To_Contour User Macro.
xp_comm_proj/vcontour/vcontapp.v contains the V definition of the example application VolumeToContourEg.
Dave Goughnour Advanced Visual Systems, Inc.
MA YingLiang Manchester Visualization Centre
contour


I live in Duckburg
My best friend is Mickey
Here are my favorite websites:
w3schools.com disney.com wikipedia.orgNote: Mouse over paragraphs, headers, and links to see what is getting a style.
Note: For :hover to work for other than links in IE, a DOCTYPE must be declared.


| I l@ve RuBoard |
Major Changes in This EditionThe best way to get a feel for any book is to read it, of course. But especially for people who are familiar with the first edition, the next few sections go into more detail about what is new in this edition. It's Been Updated for Python 2.0This edition has been updated for Python 2.0, and the Graphical User Interface (GUI) material has been updated for Tk versions 8.0 or later. Technically, this update was begun under Python 1.5.2, but all examples were revisited for 2.0 before publication. For the trivia buffs among you: release 2.0 was the first Python release following Guido's move to BeOpen, while 1.6 was the last release from Guido's prior employer, CNRI. Just before I finished this book's final draft and after the 2.0 release, Guido and the core Python development team moved from BeOpen to Digital Creations, home of the Zope web application construction kit, but this move is independent of Python releases (see Chapter 1, for more details). Release 2.0 introduces a few language extensions, but 2.0 and 1.6 are similar in content, and the updates just add a handful of features. The examples in this book should generally work with later Python releases. Remarkably, almost all examples in the first edition still work five years later, with the latest Python releases; those that didn't work required only small fixes (e.g., GUI call formats and C API interfaces). On the other hand, although the core language hasn't changed much since the first edition, a number of new constructs have been added, and we'll apply them all here. Among these new Python features: module packages, class exceptions, pseudo-private class attributes, unicode strings, the new regular expression module, new Tkinter features such as the grid manager, standard dialogs, and top-level menus, and so on. A new appendix summarizes all of the major changes in Python between the first and second editions of this book. In addition to the language changes, this book presents new Python tools and applications that have emerged in recent years. Among them: the IDLE programming interface, the JPython (a.k.a. "Jython") compiler, Active Scripting and COM extensions, the Zope web framework, Python Server Pages (PSP), restricted execution mode, the HTMLgen and SWIG code generators, thread support, CGI and Internet protocol modules, and more (it's been a busy five years). Such applications are the heart and soul of this second edition. It's Been Refocused for a More Advanced AudienceThis edition presents Python programming by advanced examples. Becoming proficient in Python involves two distinct tasks: learning the core language itself, and then learning how to apply it in applications. This edition addresses the latter (and larger) of these tasks by presenting Python libraries, tools, and programming techniques. Since this is a very different focus, I should say a few words about its rationale here. Because there were no other Python books on the horizon at the time, the first edition was written to appeal to many audiences at once -- beginners and gurus alike. Since then, another O'Reilly book, Learning Python, has been developed to address the needs of beginners, and Python Pocket Reference was published for readers seeking a short Python reference. As a result, the core language introductory-level material and the original reference appendixes have been removed from this book. Learning Python introduces the core language -- its syntax, datatypes, and so on -- using intentionally simplistic examples. Many have found it to be ideal for learning the language itself, but Python can become even more interesting once you master the basic syntax and can write simple examples at the interactive prompt. Very soon after you've learned how to slice a list, you find yourself wanting to do real things, like writing scripts to compare file directories, responding to user requests on the Internet, displaying images in a window, reading email, and so on. Most of the day-to-day action is in applying the language, not the language itself. Programming Python focuses on the "everything else" of Python development. It covers libraries and tools beyond the core language, which become paramount when you begin writing real applications. It also addresses larger software design issues such as reusability and OOP, which can only be illustrated in the context of realistically scaled programs. In other words, Programming Python, especially in this new edition, is designed to pick up where Learning Python leaves off. Therefore, if you find this book too advanced, I encourage you to read Learning Python as a prelude to this text, and return here for the rest of the story once you've mastered the basics. Unless you already have substantial programming experience, this edition might serve you best as a second Python text. It Covers New TopicsMost of the changes in this edition were made to accommodate new topics. There are new chapters and sections on Internet scripting, CGI scripts, operating system interfaces, the SWIG integration code generator, advanced Tkinter topics, the HTMLgen web page generator, JPython, threads, restricted execution mode, and more. You should consult the Table of Contents for the full scoop, but here are some of the new topics and structural changes you'll find in this edition:
Although later chapters build upon material in earlier chapters, topics in this edition are covered fairly independently, and are associated by book parts. Because of that, it's not too much of a stretch to consider this edition to be akin to four or five books in one. Its top-level structure underscores its application topics focus:
Two notes here: First of all, don't let these titles fool you -- although most have to do with application topics, Python language features and general design concepts are still explored along the way, in the context of real-world goals. Second, readers who use Python as a standalone tool can safely skip the integration chapters, though I still recommend a quick glance. C programming isn't nearly as fun or easy as Python programming. Yet because integration is central to Python's role as a scripting tool, a cursory understanding can be useful, regardless of whether you do integrating, scripting, or both. First edition readers will notice that most of this material is new, and even chapters with old titles contain largely new material. Noticeably absent in this edition are the original Sneak Preview, Mini Reference, Tutorial Appendix, and all of the old Part II -- a reflection of the new focus and intended readership. It's More Example-OrientedThis book is largely about its examples. In this edition, old examples have been extended to become more realistic (e.g., PyForm and PyCalc), and new examples have been added throughout. Among the major examples, you'll find:
There are also new mixed-mode C integration examples (e.g., callback registration and class object processing), SWIG examples (with and without "shadow" classes for C++), more Internet examples (FTP upload and download scripts, NNTP and HTTP examples, email tools, and new socket and select module examples), many new examples of Python threads, and new coverage of JPython, HTMLgen, Zope, Active Scripting, COM, and Python database interfaces. Many of the new examples are somewhat advanced, but of course this is now a somewhat advanced text. In addition, the old Python/C embedding API (now called ppembed ) has been extended to support precompiling strings to bytecode, and the original calculator example (now called PyCalc) has been beefed up to support keyboard entry, history lists, colors, and more. In fact, the new book examples tree distributed on this edition's CD-ROM (see http://examples.oreilly.com/python2) is itself a fairly sophisticated Python software system, and the examples within it have been upgraded structurally in a number of important ways:
It's More Platform-NeutralExcept for some C integration examples, the majority of the programs in this edition were developed on my Windows 98 laptop, with an eye toward portability to Linux and other platforms. In fact, some of the examples were born of my desire to provide portable Python equivalents of tools missing on Windows (e.g., file splitters). When programs are shown in action, it's usually on Windows; they are demonstrated on the Red Hat Linux 6.x platform only if they exercise Unix-specific interfaces. This is not a political statement at all -- I like Linux too. It's mostly a function of the fact that I wrote this book with MS Word; when time is tight, it's more convenient to run scripts on the same platform as your publishing tools than to frequently reboot into Linux. Luckily, because Python has now become so portable to both Windows and Linux, the underlying operating system is less of a concern to Python developers than it once was. Python, its libraries, and its Tkinter GUI framework all work extremely well on both platforms today. Because I'm not a politician, though, I've tried to make the examples as platform-neutral as possible, and point out platform-specific issues along the way. Generally speaking, most of the scripts should work on common Python platforms unchanged. For instance, all the GUI examples were tested on both Windows (98, 95) and Linux (KDE, Gnome), and most of the command-line and thread examples were developed on Windows but work on Linux too. Because Python's system interfaces are generally built to be portable, this is easier than it may sound. On the other hand, this book does delve into platform-specific topics where appropriate. There is new coverage of many Windows-specific topics -- Active Scripting, COM, program launch options, and so on. Linux and Unix readers will also find material geared towards their platforms -- forks, pipes, and the like. There is also new discussion of ways to edit and run Python programs on most major platforms. The one place where readers may still catch a glimpse of platform biases is in the Python/C integration examples. For simplicity, the C compilation details covered in this text are still somewhat Unix/Linux-biased. One can at least make a reasonable case for such a focus -- not only does Linux come with C compilers for free, but its development environment grew up around that language. On Windows, the C extension code shown in this book will work, but you may need to use different build procedures that vary per Windows compiler. O'Reilly has published an outstanding text, Python Programming on Win32, that covers Windows-specific Python topics like this, and should help address some of the disparity here. If you do Windows-specific programming, please see that book for all Windows details skipped here.
|
| I l@ve RuBoard |


TLUG welcomes members who want to volunteer for any position. You can volunteer to help as much or as little as you want. All contributions are valuable.
Current Officers
Elected
President
Edward Middleton
Vice President
Treasurer
Tim Meggs
Appointed
Sysadmin
Henri 'ragga muffin' Servomaa
Listmaster
Josh Glover
List Moderators
Webmaster
Alain Hoang Keith Bawden
Wikimaster
Alain Hoang
Editor in Chief
''Proposal: Jmglov 14:19, 28 July 2007 (JST)
Open. If you are interested, volunteer on Template ListInfo Params |tlug-admin.
Job Descriptions
Elected
President
Vice President
Treasurer
Appointed
Sysadmin
Listmaster
The duties of the Listmaster, in order of decreasing importance, are as follows:
- Ensure that the mailing list is receiving and delivering mail.
- Ensure that the list archive is functioning correctly and linked appropriately from the main site.
- Moderate the mailing list, keeping discussions on-topic, polite, and useful.
- Keep our List Policy documentation up to date and clearly stated.
- Document the current mailing list mechanism, with an eye on improvements; see also:
- TlugAdmin:Email Archives Info
- TlugAdmin:Mailing List
- Handle automatic deferrals of list-bound mail and sort the spam from the ham.
List Moderators
The duties of the List Moderators are as follows:
- Moderate the mailing list, keeping discussions on-topic, polite, and useful.
Webmaster
Wikimaster
Editor in Chief
''Proposal: Jmglov 14:19, 28 July 2007 (JST)
I envision the responsibilities of this position to be as follows, in order of decreasing importance:
- Actively encourage TLUG members to write high-quality articles that can be published on the TLUG site.
- Ensure that submitted articles meet minimal standards of quality as described above.
- Guide those articles through the submission process, as outlined by Articles:Policies:Process.
- Work with the sysadmins to make sure our bandwidth can scale to handle demand for articles.
- Work with the author to publicise his articles.
- Recruit language-specific editors to provide the same services for articles written in languages other than English.
Due to the nature of the position, only native-level English speakers should apply.
See Also
Officers


The Instant
type supports the following patterns:
The following standard patterns are supported:
g
: General format pattern.
The ISO-8601 representation of this instant in UTC, using the
pattern "yyyy-MM-ddTHH:mm:ss".
n
: Numeric with thousand separators.
This gives the number of ticks since the Unix epoch as an integer,
including thousands separators. Sample on September 16th 2011:
"13,161,548,674,473,131"
d
: Numeric without thousand separators.
This gives the number of ticks since the Unix epoch as an integer,
not including thousands separators. Sample on September 16th 2011:
"13161548674473131"
(TODO: Possibly support an "f" standard pattern which is like "g" but down to ticks.)
Instant
doesn't currently support
any custom patterns.


Ignoring her companions for a moment, Egwene al’Vere stood in her stirrups hoping for a glimpse of Tar Valon in the distance, but all she could see was something indistinct, gleaming white in the morning sunlight. It had to be the city on the island, though. The lone, broken-topped mountain called Dragonmount, rising out of the rolling plain, had first appeared on the horizon late the afternoon before, and that lay just this side of the River Erinin from Tar Valon. It was a landmark, that mountain—one jagged fang sticking up out of rolling flatlands—easily seen for many miles, easy to avoid, as all did, even those who went to Tar Valon.
Dragonmount was where Lews Therin Kinslayer had died, so it was said; and other words had been spoken of the mountain, prophecy and warning. Rich reasons to stay away from its black slopes.
She had reason not to stay away, and more than one. Only in Tar Valon could she find the training she needed, the training she had to have. I will never be collared again! She pushed the thought away, but it came back turned end about. I will never lose my freedom again! In Tar Valon, Anaiya would resume testing her dreams; the Aes Sedai would have to, though she had found no real evidence that Egwene was a Dreamer, as Anaiya suspected. Egwene’s dreams had been troubling since leaving Almoth Plain. Aside from dreams of the Seanchan—and those still made her wake sweating—she dreamed more and more of Rand. Rand running. Running toward something, but running away from something, too.
She peered harder toward Tar Valon. Anaiya would be there. And Galad, too, perhaps. She blushed in spite of herself, and banished him from her mind entirely. Think about the weather. Think about anything else. Light, but it feels warm.
This early in the year, with winter only yesterday’s memory, white still capped Dragonmount, but here below, the snows were melted. Early shoots poked through the matted brown of last year’s grasses, and where trees topped a low hill here and there, the first red of new growth was showing. After a winter spent traveling, sometimes trapped in village or camp for days by storms, sometimes covering less ground between sunrise and sunset, with snowdrifts belly-deep on the horses, than she could have walked by noon in better weather, it was good to see signs of spring.
Sweeping her thick wool cloak back out of her way, Egwene let herself drop down in the high-cantled saddle, and smoothed her skirts in a gesture of impatience. Her dark eyes filled with distaste. She had worn the dress, divided for riding by her own skill with a needle, for far too long, but the only other she had was even more grubby. And the same color, the dark gray of the Leashed Ones. The choice all those weeks ago, on beginning their ride to Tar Valon, had been dark gray or nothing.
“I swear I will never wear gray again, Bela,” she told her shaggy mount, patting the mare’s neck. Not that I’ll have much choice once we’re back in the White Tower, she thought. In the Tower, all novices wore white.
“Are you talking to yourself again?” Nynaeve asked, pulling her bay gelding closer. The two women were of a height as well as dressed alike, but the difference in their horses put the former Wisdom of Emond’s Field a head taller. Nynaeve frowned now, and tugged at the thick braid of dark hair hanging over her shoulder, the way she did when worried or troubled, or sometimes when she was preparing to be particularly stubborn even for her. A Great Serpent ring on her finger marked her as one of the Accepted, not yet Aes Sedai, but a long step closer than Egwene. “Better you should be keeping watch.”
Egwene held her tongue on the retort that she had been watching for Tar Valon. Did she think I was standing in my stirrups because I do not like my saddle? Nynaeve seemed to forget too often that she was not the Wisdom of Emond’s Field any longer, and Egwene was no longer a child. But she wears the ring and I do not—yet!—and for her, that means nothing has changed!
 The pleasure faded quickly, though. Wounding remarks did not come naturally to her, and she knew Nynaeve’s emotions concerning the Warder were like skeins of yarn after a kitten had gotten into the knitting basket.
They were six altogether, all plainly dressed enough not to stand out in the villages and small towns they had encountered, yet perhaps as odd a party as had crossed the Caralain Grass anytime recently, four of them women, and one of the men in a litter slung between two horses. The litter horses carried light packs, as well, with supplies for the long stretches between villages the way they had come.
Six people, Egwene thought, and how many secrets? They all shared more than one, secrets that would have to be kept, perhaps, even in the White Tower. Life was simpler back home.
“Nynaeve, do you think Rand is all right? And Perrin?” she added hastily. She could not afford to pretend any longer that one day she would marry Rand; pretending would be all it was, now. She did not like that—she was not entirely reconciled to it—but she knew it.
“Your dreams? Have they been troubling you again?” Nynaeve sounded concerned, but Egwene was in no mood to accept sympathy.
She made her voice sound as everyday as she could manage. “From the rumors we heard, I can’t tell what might be going on. They have everything I know about so twisted, so wrong.”
“Everything has been wrong since Moiraine came into our lives,” Nynaeve said brusquely. “Perrin and Rand . . . ” She hesitated, grimacing. Egwene thought Nynaeve believed everything that Rand had become was Moiraine’s doing. “They will have to take care of themselves for now. I’m afraid we have something to worry about ourselves. Something is not right. I can . . . feel it.”
“Do you know what?” Egwene asked.
“It feels almost like a storm.” Nynaeve’s dark eyes studied the morning sky, clear and blue, with only a few scattered white clouds, and she shook her head again. “Like a storm coming.” Nynaeve had always been able to foretell the weather. Listening to the wind, it was called, and the Wisdom of every village was expected to do it, though many really could not. Yet since leaving Emond’s Field, Nynaeve’s ability had grown, or changed. The storms she felt sometimes had to do with men rather than wind, now.
Egwene bit her underlip, thinking. They could not afford to be stopped or slowed, not after coming so far, not so close to Tar Valon. For Mat’s sake, and for reasons that her mind might tell her were more important than the life of one village youth, one childhood friend, but that her heart could not rate so high. She looked at the others, wondering if any of them had noticed something.
Verin Sedai, short and plump and all in shades of brown, rode apparently lost in thought, the hood of her cloak pulled forward till it all but hid her face, in the lead but letting her horse amble at its own pace. She was of the Brown Ajah, and the Brown sisters usually cared more for seeking out knowledge than for anything in the world around them. Egwene was not so sure of Verin’s detachment, though. Verin had put herself hip-deep in the affairs of the world by being with them.
Elayne, of an age with Egwene and also a novice, but golden-haired and blue-eyed where Egwene was dark, rode back beside the litter where Mat lay unconscious. In the same gray as Egwene and Nynaeve, she was watching him with the worry they all felt. Mat had not roused in three days, now. The lean, long-haired man riding on the other side of the litter seemed to be trying to look everywhere without anyone noticing, and the lines of his face had deepened in concentration.
“Hurin,” Egwene said, and Nynaeve nodded. They slowed to let the litter catch up to them. Verin ambled on ahead.
“Do you sense something, Hurin?” Nynaeve asked. Elayne lifted her eyes, suddenly intent, from Mat’s litter.
With the three of them looking at him, the lean man shifted in his saddle and rubbed the side of his long nose. “Trouble,” he said, curt and reluctant at the same time. “I think maybe . . . trouble.”
A thief-taker for the King of Shienar, he did not wear a Shienaran warrior’s topknot, yet the short sword and notched sword-breaker at his belt were worn with use. Years of experience seemed to have given him some talent at sniffing out wrongdoers, especially those who had done violence.
Twice on the journey he had advised them to leave a village after being there less than an hour. The first time, they had all refused, saying they were too tired, but before the night was done the innkeeper and two other men of the village had tried to murder them in their beds. They were only simple thieves, not Darkfriends, just greedy for the horses and whatever they had in their saddlebags and bundles. But the rest of the village knew of it, and apparently considered strangers fair gleanings. They had been forced to flee a mob waving axe handles and pitchforks. The second time, Verin ordered them to ride on as soon as Hurin spoke.
But the thief-taker was always wary when talking to any of his companions. Except Mat, back when Mat could talk; the two of them had joked and played at dice, when the women were not too close at hand. Egwene thought he might be uneasy at being alone, for all practical purposes, with an Aes Sedai and three women in training for sisterhood. Some men found facing a fight easier than facing Aes Sedai.
“What kind of trouble?” Elayne said.
She spoke easily, but with such a clear note of expecting to be answered, immediately and in detail, that Hurin opened his mouth. “I smell—” He cut himself short and blinked as if surprised, eyes darting from one woman to another. “Just a feeling,” he said finally. “A . . . a hunch. I’ve seen some tracks, yesterday, and today. A lot of horses. Twenty or thirty going this way, twenty or thirty that. It makes me wonder. That’s all. A feeling. But I say it’s trouble.”
Tracks? Egwene had not noticed them. Nynaeve said sharply, “I did not see anything worrisome in them.” Nynaeve prided herself on being as good a tracker as any man. “They were days old. What makes you think they are trouble?”
“I just think they are,” Hurin said slowly, as if he wanted to say more. He dropped his eyes, rubbing at his nose and inhaling deeply. “It’s been a long time since we saw a village,” he muttered. “Who knows what news from Falme has come before us? We might not find so good a welcome as we expect. I’m thinking these men could be brigands, killers. We should be wary, I’m thinking. If Mat was on his feet, I’d scout ahead, but maybe it’s best I don’t leave you alone.”
Nynaeve’s eyebrows lifted. “Do you believe we cannot look after ourselves?”
“The One Power won’t do you much good if somebody kills you before you can use it,” Hurin said, addressing the tall pommel of his saddle. “Begging your pardon, but I think I . . . I’ll just ride up with Verin Sedai for a time.” He dug in his heels and galloped forward before any of them could speak again.
“Now that is a surprise,” Elayne said as Hurin slowed a little distance from the Brown sister. Verin did not seem to notice him any more than she noticed anything else, and he appeared content to leave it so. “He has been staying as far from Verin as he could ever since we left Toman Head. He always looks at her as if he’s afraid of what she might say.”
“Respecting Aes Sedai doesn’t mean he is not afraid of them,” Nynaeve said, then added, reluctantly, “Of us.”
“If he thinks there might be trouble, we ought to send him out scouting.” Egwene took a deep breath and gave the other two women as level a look as she could manage. “If there is trouble, we can defend ourselves better than he could with a hundred soldiers to help him.”
“He doesn’t know that,” Nynaeve said, flatly, “and I am not about to tell him. Or anyone else.”
“I can imagine what Verin would have to say about it.” Elayne sounded anxious. “I wish I had some idea how much she does know. Egwene, I don’t know if my mother could help me if the Amyrlin found out, much less help the pair of you. Or even whether she would try.” Elayne’s mother was Queen of Andor. “She was only able to learn a little of the Power before she left the White Tower, for all she has lived as if she had been raised to full sister.”
“We cannot hope to rely on Morgase,” Nynaeve said. “She is in Caemlyn, and we will be in Tar Valon. No, we may be in enough trouble already for going off as we did, no matter what we’ve brought back. It will be best if we stay low, behave humbly, and do nothing to attract more attention than we already have.”
Another time, Egwene would have laughed at the idea of Nynaeve pretending to be humble. Even Elayne managed a better job of it. But at present she did not feel like laughing. “And if Hurin is right? If we are attacked? He cannot defend us against twenty or thirty men, and we might be dead if we wait for Verin to do something. You said you sense a storm, Nynaeve.”
“You do?” Elayne said. Red-gold curls swung as she shook her head. “Verin will not like it if we . . .  “Whatever Verin likes or doesn’t like, we may have to.”
“I will do what must be done,” Nynaeve said sharply, “if there is anything to be done, and you two will run, if need be. The White Tower may be all abuzz with your potential, but don’t think they will not still you both if the Amyrlin Seat or the Hall of the Tower decides it is necessary.”
Elayne swallowed hard.  We should all run together or act together. Hurin has been right before. If we want to live to be in trouble in the Tower, we may have to . . . to do what we must.”
Egwene shivered. Stilled. Cut off from saidar, the female half of the True Source. Few Aes Sedai had ever incurred that penalty, yet there were deeds for which the Tower demanded stilling. Novices were required to learn the names of every Aes Sedai who had ever been stilled, and their crimes.
She could always feel the Source there, now, just out of sight, like the sun at noon over her shoulder. If she often caught nothing when she tried to touch saidar, she still wanted to touch it. The more she touched it, the more she wanted to, all the time, no matter what Sheriam Sedai, the Mistress of Novices, said about the dangers of growing too fond of the feel of the One Power. To be cut off from it; still able to sense saidar, but never to touch it again . . .
Neither of the others seemed to want to talk, either.
To cover her shaking, she bent from her saddle to the gently swaying litter. Mat’s blankets had become disarrayed, exposing a curved dagger in a golden sheath clutched in one hand, a ruby the size of a pigeon’s egg capping the hilt. Careful not to touch the dagger, she eased the blankets back over his hand. He was only a few years older than she, but gaunt cheeks and sallow skin had aged him. His chest barely moved as he breathed hoarsely. A lumpy leather sack lay at his feet. She shifted the blanket to cover that, too. We have to get Mat to the Tower, she thought. And the sack.
Nynaeve leaned down as well, and felt Mat’s forehead. “His fever is worse.” She sounded worried. “If only I had some worrynot root or feverbane.”
“Perhaps if Verin tried Healing again,” Elayne said.
Nynaeve shook her head. She smoothed Mat’s hair back and sighed, then straightened before speaking. “She says it is all she can do to keep him alive, now, and I believe her.
Elayne gasped. “Sheriam Sedai says we mustn’t try to Heal until we’ve been guided step by step a hundred times.”
“You could have killed him,” Egwene said sharply.
Nynaeve sniffed loudly. “I was Healing before I ever thought of going to Tar Valon, even if I didn’t know I was. But it seems I need my medicines to make it work for me. If I only had some feverbane. I do not think he has much time left. Hours, maybe.”
Egwene thought she sounded almost as unhappy about knowing, about how she knew, as she did about Mat. She wondered again why Nynaeve had chosen to go to Tar Valon for training at all. She had learned to channel unknowingly, even if she could not always control the act, and had passed the crisis that killed three out of four women who learned without Aes Sedai guidance. Nynaeve said she wanted to learn more, but often she was as reluctant about it as a child being dosed with sheepstongue root.
“We will have him in the White Tower soon,” Egwene said. “They can Heal him there. The Amyrlin will take care of him. She will take care of everything.” She did not look at where Mat’s blanket covered the sack at his feet. The other two women were studiously not looking at it, either. There were some secrets they would all be relieved to shed.
“Riders,” Nynaeve said suddenly, but Egwene had already seen them. Two dozen men appearing over a low rise ahead, white cloaks flapping as they galloped, angling toward them.
“Children of the Light,” Elayne said, like a curse. “I think we have found your storm, and Hurin’s trouble.”
Verin had pulled up, a hand on Hurin’s arm to stop him drawing his sword. Egwene touched the lead litter horse to stop it just behind the plump Aes Sedai.
“Let me do all the talking, children,” the Aes Sedai said placidly, pushing her cowl back to reveal gray in her hair. Egwene was not sure how old Verin was; she thought old enough to be a grandmother, but the gray streaks were the Aes Sedai’s only signs of age.
Verin’s face was as calm as her voice, but Egwene thought she saw the Aes Sedai measuring the distance to Tar Valon. The tops of the towers were visible now, and a high bridge arching over the river to the island, tall enough for the trading ships that plied the river to sail beneath.
Close enough to see, Egwene thought, but too far to do any good.
For a moment she was sure the oncoming Whitecloaks meant to charge them, but their leader raised a hand and they abruptly drew rein a scant forty paces off, scattering dust and dirt ahead of them.
Nynaeve muttered angrily under her breath, and Elayne sat straight and full of pride, appearing likely to berate the Whitecloaks for ill manners. Hurin still had a grip on his sword hilt; he looked ready to put himself between the women and the Whitecloaks no matter what Verin said.  The white-cloaked riders spread out in an arc, blocking the way firmly.
Their breastplates and conical helmets shone from polishing, and even the mail on their arms gleamed brightly. Each man had the flaring, golden sun on his breast. Some fitted arrows to bows, which they did not raise, but held ready. Their leader was a young man, yet he wore two golden knots of rank beneath the sunburst on his cloak.
“Two Tar Valon witches, unless I miss my guess, yes?” he said with a tight smile that pinched his narrow face.  “And two nits, and a pair of lapdogs, one sick and one old.” Hurin bristled, but Verin’s hand restrained him. “Where do you come from?” the Whitecloak demanded.
“We come from the west,” Verin said placidly. “Move out of our way, and let us continue. The Children of the Light have no authority here.”
“The Children have authority wherever the Light is, witch, and where the Light is not, we bring it. Answer my questions! Or must I take you to our camp and let the Questioners ask?”
Mat could not afford any more delay in reaching help in the White Tower. And more importantly—Egwene winced to think of it that way—more importantly, they could not let the contents of that sack fall into Whitecloak hands.
“I have answered you,” Verin said, still calm, “and more politely than you deserve. Do you really believe you can stop us?” Some of the Whitecloaks raised their bows as if she had uttered a threat, but she went on, her voice never rising. “In some lands you may hold sway by your threats, but not here, in sight of Tar Valon. Can you truly believe that in this place, you will be allowed to carry off Aes Sedai?”
The officer shifted uneasily in his saddle, as though suddenly doubting whether he could back up his words. Then he glanced back at his men—either to remind himself of their support or because he had remembered they were watching—and with that he took himself in hand. “I have no fear of your Darkfriend ways, witch. Answer me, or answer the Questioners.” He did not sound as forceful as he had.
Verin opened her mouth as if for idle conversation, but before she could speak, Elayne jumped in, voice ringing with command. “I am Elayne, Daughter-Heir of Andor. If you do not move aside at once, you will have Queen Morgase to answer to, Whitecloak!” Verin hissed with vexation.
The Whitecloak looked taken aback for an instant, but then he laughed. “You think it so, yes? Perhaps you will discover Morgase no longer has so much love for witches, girl. If I take you from them and return you to her side, she will thank me for it. Lord Captain Eamon Valda would like very much to speak to you, Daughter-Heir of Andor.” He raised a hand, whether to gesture or signal his men, Egwene could not say. Some of the Whitecloaks gathered their reins.
There’s no more time to wait, Egwene thought. I will not be chained again! She opened herself to the One Power. It was a simple exercise, and after long practice, it went much more swiftly than the first time she had tried. In a heartbeat her mind emptied of everything, everything but a single rosebud, floating in emptiness. She was the rosebud, opening to the light, opening to saidar, the female half of the True Source. The Power flooded her, threatening to sweep her away. It was like being filled with light, with the Light, like being one with the Light, a glorious ecstasy. She fought to keep from being overwhelmed, and focused on the ground in front of the Whitecloak officer’s horse.  You will not take me!
The man’s hand was still going up.  Screaming, his horse reared, and he rolled out of his saddle like a sack.
Before he hit the ground, Egwene shifted her focus closer to the other Whitecloaks, and the ground threw up another small explosion. Bela danced sideways, but she controlled the mare with reins and knees without even thinking of it. Wrapped inside emptiness, she was still surprised at a third eruption, not of her making, and a fourth. Distantly, she was aware of Nynaeve and Elayne, both enveloped in the glow that said they, too, had embraced saidar, had been embraced by it. That aura would not be visible to any but another woman who could channel, but the results were visible to all. Explosions harried the Whitecloaks on every side, showering them with dirt, shaking them with noise, sending their horses plunging wildly.
Hurin stared around him, mouth open and obviously as frightened as the Whitecloaks, as he tried to keep the litter horses and his own mount from bolting. Verin was wide-eyed with astonishment and anger. Her mouth worked furiously, but whatever she might be saying was lost in the thunder.
And then the Whitecloaks were running away, some dropping their bows in panic, galloping as if the Dark One himself were at their backs. All but the young officer, who was picking himself up off the ground. Shoulders hunched, he stared at Verin, the whites of his eyes showing all the way ’round. Dust stained his fine white cloak, and his face, but he did not seem to notice. “Kill me, then, witch,” he said shakily. “Go ahead.
The Aes Sedai ignored him. Her attention was all on her companions. As if they, too, had forgotten their officer, the fleeing Whitecloaks vanished over the same rise where they had first appeared, all in a body and none looking back. The officer’s horse ran with them.
Under Verin’s furious gaze, Egwene let go of saidar, slowly, unwillingly. It was always hard, letting go. Even more slowly, the glow around Nynaeve vanished. Nynaeve was frowning hard at the pinch-faced Whitecloak before them, as if he might still be capable of some sort of trickery. Elayne looked shocked by what she had done.
“What you have done,” Verin began, then stopped to take a deep breath. Her stare took in all three of the younger women. “What you have done is an abomination. An abomination! An Aes Sedai does not use the Power as a weapon except against Shadowspawn, or in the last extreme to defend her life. The Three Oaths—”
“They were ready to kill us,” Nynaeve broke in heatedly.  He was giving the order.”
“It . . . it was not really using the Power as a weapon, Verin Sedai.” Elayne held her chin high, but her voice shook. “We did not hurt anyone, or even try to hurt anyone. Surely—”
“Do not split hairs with me!” Verin snapped. “When you become full Aes Sedai—if you ever become full Aes Sedai!—you will be bound to obey the Three Oaths, but even novices are expected to do their best to live as if already bound.”
“What about him?” Nynaeve gestured to the Whitecloak officer, still standing there and looking stunned. Her face was as tight as a drum; she seemed almost as angry as the Aes Sedai. “He was about to take us prisoner.  ”
Egwene knew what Nynaeve was struggling not to say aloud. And we can’t let that sack fall into any hands but the Amyrlin’s.
Verin regarded the Whitecloak wearily. “He was only trying to bully us, child. He knew very well he could not make us go where we did not want, not without more trouble than he was willing to accept. Not here, not in sight of Tar Valon. I could have talked us past him, with a little time and a little patience. Oh, he might well have tried to kill us if he could have done it from hiding, but no Whitecloak with the brains of a goat will try harming an Aes Sedai who knows he is there. See what you have done! What stories will those men tell, and what harm will it do?”
The officer’s face had reddened when she mentioned hiding. “It is no cowardice not to charge the powers that Broke the World,” he burst out. “You witches want to Break the World again, in the service of the Dark One!” Verin shook her head in tired disbelief.
Egwene wished she could mend some of the damage she had done. “I am very sorry for what I did,” she told the officer. She was glad she was not bound to speak no word that was not true, as full Aes Sedai were, because what she had said was only half true at best. “I should not have, and I apologize. I am sure Verin Sedai will Heal your bruises.” He stepped back as if she had offered to have him skinned alive, and Verin sniffed loudly. “We have come a long way,” Egwene went on, “all the way from Toman Head, and if I weren’t so tired, I would never have—”
“Be quiet, girl!” Verin shouted at the same time the Whitecloak snarled, “Toman Head? Falme! You were at Falme!” He stumbled back another step and half drew his sword. From the look on his face, Egwene did not know whether he meant to attack, or to defend himself. Hurin moved his horse closer to the Whitecloak, a hand on his swordbreaker, but the narrow-faced man went on in a rant, spittle flying with his fury. “My father died at Falme! Byar told me! You witches killed him for your false Dragon! I’ll see you dead for it! I will see you burn!”
“Impetuous children,” Verin sighed.  Go with the Light, my son,” she told the Whitecloak.
Without another word, she guided them around the man, but his shouts followed after. “My name is Dain Bornhald! Remember it, Darkfriends! I will make you fear my name! Remember my name!”
As Bornhald’s shouts faded behind them, they rode in silence for a time. Finally, Egwene said to no one in particular, “I was only trying to make things better.”
“Better!” Verin muttered. “You must learn there is a time to speak all of the truth, and a time to govern your tongue. The least of the lessons you must learn, but important, if you mean to live long enough to wear the shawl of a full sister. Did it never occur to you that word of Falme might have come ahead of us?”
“Why should it have occurred to her?” Nynaeve asked. “No one we’ve met before this had heard more than rumors, if that, and we have outrun even rumor in the last month.”
“And all word has to come along the same roads we used?” Verin replied. “We have moved slowly. Rumor takes wing along a hundred paths. Always plan for the worst, child; that way, all your surprises will be pleasant ones.”
“What did he mean about my mother?” Elayne said suddenly. “He must have been lying. She would never turn against Tar Valon.”
“The Queens of Andor have always been friends to Tar Valon, but all things change.” Verin’s face was calm again, yet there was a tightness in her voice. She turned in her saddle to look over them, the three young women, Hurin, Mat in the litter. “The world is strange, and all things change.” They capped the ridge; a village was in sight ahead of them now, yellow tile roofs clustered around the great bridge that led to Tar Valon. “Now you must truly be on your guard,” Verin told them. “Now the real danger begins.”


Thinking in terms of vectors and matrices¶
| Learning Objectives | |
|---|---|
| 1 | Become familiar with linear algebra’s basic data structures: scalar, vector, matrix, tensor |
| 2 | Create, manipulate, and generally begin to get comfortable with NumPy arrays |
So you may be asking why?¶
Here are just a few reasons why a solid understanding of linear algebra is crutial for a practicing data scientist
- Linear models can concisly be written in vector notation
- Regularization often makes use of matrix norms
- Matrix decompsitions are commonly used in recommender systems
Scalars, vectors, matrices and tensors¶
Without knowing anything about vectors or matrices there is already a good chance that you have some intuition for these concepts. Think of a spreadsheet with rows and columns. Within a given cell there exists some value—lets call it a scalar; scalars are the contents of vectors and matrices. If we think of the idea of a column and the elements contained therein we now have a basis for the concept of a vector. More specifically, this is referred to as a column vector. The elements of a row are accordingly referred to as a row vector.
We collectively refer to the columns and rows as matrix.
Note
A matrix with \(m\) rows and \(n\) columns is a \(m \times n\) matrix and we refer to \(m\) and \(n\) as dimensions.
If a matrix is a two dimensional representation of data then a tensor is the generalization of that representation to any number of dimensions. Lets say we copied our spreadsheet and created several new tabs then we are now working with a tensor.
| Machine Learning | Notation | Description |
|---|---|---|
| Scaler | \(x\) | a single real number (ints, floats etc) |
| Vector | \(\mathbf{x}\) or \(\mathbf{x}^{T}\) | a 1D array of numbers (real, binary, integer etc) |
| Matrix | \(\mathbf{X}\) | a 2D array of numbers |
| Tensor | \(\hat{f}\) | an array generalized to n dimensions |
Matrices are also tensors. If we were working with a \(4 \times 4\) matrix it can be described as a tensor of rank 2. The rank is the formal term for the number of dimensions.
Questions
- So what are the dimensions of the following matrix
The matrix dimensions are \(3 \times 4\)
- Given a spreadsheet that has 4 tabs and each tab has 2 rows with 3 columns how might we represent that data with a tensor?
The tensor would be of rank 3 and have the following dimensions \(2 \times 3 \times 4\). In NumPy this is written as a \(4 \times 2 \times 3\). You will soon be working with NumPy and you can refer back to this example.
>>> x = np.array([[[ 0, 1, 2],
[ 3, 4, 5]],
[[ 9, 10, 11],
[15, 16, 17]],
[[ 2, 10, 8],
[5, 4, 9]],
[[18, 19, 20],
[24, 25, 26]]])
>>> print(x.shape)
(4, 2, 3)
Notation¶
Scalers have the standard math notation
\[x = 1\]
Vectors are denoted by lower case bold letters such as \(\mathbf{x}\), and all vectors are assumed to be column vectors.
\[\begin{split}\mathbf{x} = \begin{pmatrix} 0 \\ 1 \\ 2 \\ 3 \end{pmatrix}\end{split}\]
A superscript \(T\) denotes the transpose of a matrix or vector. This implies that \(\mathbf{x}^{T}\) is a row vector.
\[\mathbf{x}^{T} = \begin{pmatrix} 0 & 1 & 2 & 3 \end{pmatrix}\]
Upper-case bold letter denote.
\[\begin{split}\mathbf{X} = \begin{pmatrix} 0 & 0 & 1 & 0 \\ 1 & 2 & 0 & 1 \\ 1 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
An introduction to NumPy and Arrays¶
Sometimes we need to write concepts on paper or see them in action through code before we can effectively establish our understanding. We will be learning the through a widely used Python package called NumPy to help bring to life the essentials of linear algebra.
In order to get the most out of this resource and to ensure that you can actively follow along it is easiest if you install a working Python environment.
Important
Familiarity with the Python language is not a prerequisite for this primer. The included code blocks are minimal and you should be able to follow even without prior experience in Python.
Once Python is installed you can start an interactive Python
environment by typing the command ipython
into a terminal. NumPy is the de facto standard for numerical computing
in Python and it comes installed as part of the Conda bundle. It is
highly optimized and
extremely useful for working with matrices. The standard matrix class
in NumPy is called an array.
We will first get comfortable working with arrays then we will ease
our way into the essential concepts of linear algebra. NumPy will
provide you with a tool explore all concepts presented here.
The standard syntax for importing the package NumPy into a Python environment is
>>> import numpy as np
Note
Examples of code (like the import statement above) are line by line, where each line begins with >>>. This means that you can copy the code that comes after the line indicator directly into your interpreter
Arrays and their attributes¶
Python is an object-oriented programming language. The main object in NumPy is the homogeneous, multidimensional array. An array is our programmatic way to represent vectors and matrices. An example is a matrix \(\mathbf{X}\)
and can be represented through NumPy as
>>> import numpy as np
>>> X = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> X
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
Lets break down that code statement. First
>>> a = [1,2,3]
is a native Python data structure called a list. We could create a vector from this list using the NumPy array class.
>>> a = np.array([1,2,3])
So to create the above X matrix it is a list of lists where each row corresponds to a list.
Because our array version of \(\mathbf{X}\) is an object it contains methods and attributes.
- The methods are functions that act on our matrix
- the attributes are data that are related to our matrix.
Lets start with some useful attributes. The array \(\mathbf{X}\)
has 2 dimensions. The number of dimensions in linear algebra
terminology is referred to as rank. We get at rank with the
ndim
attribute.
>>> X.ndim
2
similarly we have access to the dimensions themselves through shape
>>> X.shape
(3, 3)
Note that the number of axes is also equal to the or the length of x.shape
. To return an integer representing the total number of elements one may use size
.
>>> X.size
9
Warning
If you want to work with a vector where the dimensions exist explicitly you need to use double brackets. Otherwise it will be a 1D matrix and sometimes it may not give you the result you were looking for.
>>> np.array([1,2,3]).shape
(3,)
>>> np.array([[1,2,3]]).shape
(1, 3)
Arrays and their methods¶
We have seen that arrays have built in attributes that are useful. They also have numerous built-in methods that make them particularly convenient. Note that methods always have parenthesis that may or may not enclose arguments.
>>> X.sum(axis=0)
array([12, 15, 18])
>>> X.sum(axis=1)
array([ 6, 15, 24])
>>> X.mean(axis=0)
array([ 4., 5., 6.])
>>> X.mean(axis=1)
array([ 2., 5., 8.])
Commonly used arrays can be created with functions that are part of the NumPy package. For example, to make a sequence of numbers, we can use arange. This is similar to the standard python function range that returns a list instead of an array. Look carefully at the following examples to see how it works.
>>> np.arange(10)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.arange(5,10)
array([5, 6, 7, 8, 9])
>>> np.arange(5,10,0.5)
array([ 5. , 5.5, 6. , 6.5, 7. , 7.5, 8. , 8.5, 9. , 9.5])
Also we can recreate the first matrix by reshaping the output of arange.
>>> X = np.arange(1,10).reshape(3,3)
>>> X
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
In that function we created an array with values from 1-10 then we reshaped it into a 2D array with 3 columns and 3 rows. Another similar function to arange is linspace which fills a vector with evenly spaced variables for a specified interval.
>>> x = np.linspace(0,5,5)
>>> x
array([ 0. , 1.25, 2.5 , 3.75, 5. ])
As a reminder you may access the Python documentation at anytime from the command line using
~$ pydoc numpy.linspace
The following plot visualizes linspace
. It is an important function, but it less important that you understand the plotting portion of the code.
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
N = 8
y = np.zeros(N)
x1 = np.linspace(0, 10, N, endpoint=True)
p1 = plt.plot(x1, y, 'o')
ax.set_xlim([-0.5,10.5])
plt.show()
(Source code, png, hires.png, pdf)
Important
Did you notice that arange
starts counting at zero?
Python uses zero based indexing, so the initial element
of a sequence has index 0.
This is a good time to introduce the idea that arrays may be made of different types of data, but they can only be one data type at a given time.
>>> x = np.array([1,2,3])
>>> x.dtype
dtype('int64')
>>> x = np.array([0.1,0.2,0.3])
>>> x
array([ 0.1, 0.2, 0.3])
>>> x.dtype
dtype('float64')
>>> x = np.array([1,2,3],dtype='float64')
>>> x.dtype
dtype('float64')
There are several convenience functions for making arrays that you should be aware of:
>>> x = np.zeros([3,4])
>>> x
array([[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.]])
>>> x = np.ones([3,4])
>>> x
array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.]])
Exercise
- Create the following matrix using a NumPy array (1 line)
>>> a = np.arange(1,101).reshape(10,10)
- Use the array object to get the rank, number of elements, and dimensions
>>> print("Rank: {}\nSize: {}\nDimensions: {}".format(a.ndim,a.size,a.shape))
Rank: 2
Size: 100
Dimensions: (10, 10)
- Get the mean of the rows and columns
>>> print("Row means: {}".format(a.mean(axis=1)))
Row means: [ 5.5 15.5 25.5 35.5 45.5 55.5 65.5 75.5 85.5 95.5]
>>> print("Column means: {}".format(a.mean(axis=0)))
Column means: [ 46. 47. 48. 49. 50. 51. 52. 53. 54. 55.]
- How do you create a vector that has exactly 50 points and spans the range 11 to 23?
>>> b = np.linspace(11,23,50)
[extra] If you want a peak at whats to come see what happens when you do the following
- np.log(a)
- np.cumsum(a)
- np.power(a,2)