Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
docs:tutorial [2016/11/30 12:34] – sbs | docs:tutorial [2017/03/24 20:39] – tema |
---|
<!DOCTYPE html><html> | <html> |
<head> | <head> |
<title>Untitled Document</title> | <title>Untitled Document</title> |
<!--Generated on Wed Nov 30 11:29:29 2016 by LaTeXML (version 0.8.2) http://dlmf.nist.gov/LaTeXML/.--> | <!-- Generated on Fri Mar 24 19:34:06 2017 by LaTeXML (version 0.8.2) http://dlmf.nist.gov/LaTeXML/. --> |
| |
| <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> |
| <!-- autoinlined `/tmp/docs/tutorial/html/LaTeXML.css' --> |
| <style type='text/css'> |
| /*====================================================================== |
| Core CSS for LaTeXML documents converted to (X)HTML */ |
| /* Generic Page layout */ |
| .ltx_page_header, |
| .ltx_page_footer { font-size:0.8em; } |
| .ltx_page_header *[rel~="prev"], |
| .ltx_page_footer *[rel~="prev"] { float:left; } |
| .ltx_page_header *[rel~="up"], |
| .ltx_page_footer *[rel~="up"] { display:block; text-align:center; } |
| .ltx_page_header *[rel~="next"], |
| .ltx_page_footer *[rel~="next"] { float:right; } |
| /* What was I trying for here; need more selective rule! |
| .ltx_page_header .ltx_ref, |
| .ltx_page_footer .ltx_ref { |
| margin:0 1em; } |
| */ |
| .ltx_page_header li { |
| padding:0.1em 0.2em 0.1em 1em;} |
| |
| /* Main content */ |
| .ltx_page_content { clear:both; } |
| .ltx_page_header { border-bottom:1px solid; margin-bottom:5px; } |
| .ltx_page_footer { clear:both; border-top:1px solid; margin-top:5px; } |
| |
| .ltx_page_header:after, |
| .ltx_page_footer:after, |
| .ltx_page_content:after { |
| content:"."; display:block; height:0; clear:both; visibility:hidden; } |
| .ltx_page_footer:before { |
| content:"."; display:block; height:0; clear:both; visibility:hidden; } |
| |
| .ltx_page_logo { font-size:80%; margin-top: 5px; clear:both; float:right; } |
| .ltx_page_logo a { font-variant: small-caps; } |
| .ltx_page_logo img { vertical-align:-3px; } |
| |
| /* if shown */ |
| .ltx_page_navbar li { white-space:nowrap; display:block; overflow:hidden; } |
| /* If ref got turned into span, it's "this section"*/ |
| .ltx_page_navbar li span.ltx_ref { white-space:normal; overflow:visible; } |
| |
| /* Ought to be easily removable/overridable? */ |
| .ltx_pagination.ltx_role_newpage { height:2em; } |
| /*====================================================================== |
| Document Structure; Titles & Frontmatter */ |
| |
| /* undo bold here to remove the browser's native h# styling, |
| at let all other styles override it (with more specific rules)*/ |
| .ltx_title { font-size:100%; font-weight:normal; } |
| |
| /* Hack to simulate run-in! put class="ltx_runin" on a title or tag |
| for it to run-into the following text. */ |
| .ltx_runin { display:inline; } |
| .ltx_runin:after { content:" "; } |
| .ltx_runin + .ltx_para, |
| .ltx_runin + .ltx_para p, |
| .ltx_runin + p { display:inline; } |
| |
| .ltx_outdent { margin-left: -2em; } |
| |
| /* .ltx_chapter_title, etc should be in ltx-article.css etc. |
| */ |
| .ltx_page_main { margin:0px; padding:1em 3em 1em 2em; } |
| .ltx_tocentry { list-style-type:none; } |
| |
| /* support for common author block layouts.*/ |
| /* add class ltx_authors_1line to get authors in single line |
| with pop-up affiliation, etc. */ |
| .ltx_authors_1line .ltx_creator, |
| .ltx_authors_1line .ltx_author_before, |
| .ltx_authors_1line .ltx_author_after { display:inline;} |
| .ltx_authors_1line .ltx_author_notes { display:inline-block; } |
| .ltx_authors_1line .ltx_author_notes:before { content:"*"; color:blue;} |
| .ltx_authors_1line .ltx_author_notes span { display:none; } |
| .ltx_authors_1line .ltx_author_notes:hover span { |
| display:block; position:absolute; z-index:10; |
| background:white; text-align:left; |
| border: 1px solid black; border-radius: 0 5px 5px 5px; box-shadow: 5px 5px 10px gray; } |
| |
| /* add class=ltx_authors_multiline to get authors & affliations on separate lines*/ |
| .ltx_authors_multiline .ltx_creator, |
| .ltx_authors_multiline .ltx_author_before, |
| .ltx_authors_multiline .ltx_author_after, |
| .ltx_authors_multiline .ltx_author_notes, |
| .ltx_authors_multiline .ltx_author_notes .ltx_contact { |
| display:block; } |
| |
| /*====================================================================== |
| Para level */ |
| .ltx_float { |
| margin: 1ex 3em 1ex 3em; } |
| td.ltx_subfigure, |
| td.ltx_subtable, |
| td.ltx_subfloat { width:50%; } |
| /* theorems, figure, tables, floats captions.. */ |
| /*====================================================================== |
| Blocks, Lists, Floats */ |
| .ltx_p, |
| .ltx_quote, |
| .ltx_block, |
| .ltx_para { |
| display: block; } |
| |
| /* alignment within blocks */ |
| .ltx_align_left { text-align:left; } |
| .ltx_align_right { text-align:right; } |
| .ltx_align_center { text-align:center; } |
| .ltx_align_justify { text-align:justify; } |
| .ltx_align_top { vertical-align:top; } |
| .ltx_align_bottom { vertical-align:bottom; } |
| .ltx_align_middle { vertical-align:middle; } |
| .ltx_align_baseline { vertical-align:baseline; } |
| |
| .ltx_align_floatleft { float:left; } |
| .ltx_align_floatright { float:right; } |
| |
| .ltx_td.ltx_align_left, .ltx_th.ltx_align_left, |
| .ltx_td.ltx_align_right, .ltx_th.ltx_align_right, |
| .ltx_td.ltx_align_center, .ltx_th.ltx_align_center { white-space:nowrap; } |
| .ltx_td.ltx_align_left.ltx_wrap, .ltx_th.ltx_align_left.ltx_wrap, |
| .ltx_td.ltx_align_right.ltx_wrap, .ltx_th.ltx_align_right.ltx_wrap, |
| .ltx_td.ltx_align_center.ltx_wrap, .ltx_th.ltx_align_center.ltx_wrap { white-space:normal; } |
| |
| .ltx_inline-block { display:inline-block; } |
| |
| /* equations in non-aligned mode (not normally used) */ |
| .ltx_eqn_div { display:block; width:95%; text-align:center; } |
| |
| /* equations in aligned mode (aligning tags, etc as well as equations) */ |
| .ltx_eqn_table { display:table; width:100%; border-collapse:collapse; } |
| .ltx_eqn_row { display:table-row; } |
| .ltx_eqn_cell { display:table-cell; width:auto; } |
| |
| .ltx_tag_equationgroup.ltx_align_left, |
| .ltx_tag_equation.ltx_align_left{ position:absolute; left:3em; } |
| .ltx_tag_equationgroup.ltx_align_right, |
| .ltx_tag_equation.ltx_align_right{ position:absolute; right:3em; } |
| |
| |
| table.ltx_eqn_align tr.ltx_equation td.ltx_align_left + td.ltx_align_right { padding-left:3em; } |
| table.ltx_eqn_eqnarray tr.ltx_eqn_lefteqn + tr td.ltx_align_right { min-width:2em; } |
| |
| .ltx_eqn_eqno { max-width:0em; overflow:visible; } |
| .ltx_eqn_eqno.ltx_align_right .ltx_tag { float:right; } |
| |
| .ltx_eqn_center_padleft, |
| .ltx_eqn_center_padright { width:50%; min-width:2em;} |
| .ltx_eqn_left_padleft, |
| .ltx_eqn_right_padright { min-width:2em; } |
| .ltx_eqn_left_padright, |
| .ltx_eqn_right_padleft { width:100%; } |
| |
| /* Various lists */ |
| .ltx_itemize, |
| .ltx_enumerate, |
| .ltx_description { |
| display:block; } |
| .ltx_itemize .ltx_item, |
| .ltx_enumerate .ltx_item { |
| display: list-item; } |
| |
| /* Position the tag to look like a normal item bullet. */ |
| li.ltx_item > .ltx_tag { |
| display:inline-block; margin-left:-1.5em; min-width:1.5em; |
| text-align:right; } |
| .ltx_item .ltx_tag + .ltx_para, |
| .ltx_item .ltx_tag + .ltx_para .ltx_p { display:inline; } |
| |
| /* NOTE: Need to try harder to get runin appearance? */ |
| dl.ltx_description dt { margin-right:0.5em; float:left; |
| font-weight:bold; font-size:95%; } |
| dl.ltx_description dd { margin-left:5em; } |
| dl.ltx_description dl.ltx_description dd { margin-left:3em; } |
| |
| /* Theorems */ |
| .ltx_theorem {margin:1em 0em 1em 0em; } |
| .ltx_title_theorem { font-size:100%; } |
| |
| /* Bibliographies */ |
| .ltx_bibliography dt { margin-right:0.5em; float:left; } |
| .ltx_bibliography dd { margin-left:3em; } |
| /*.ltx_biblist { list-style-type:none; }*/ |
| .ltx_bibitem { list-style-type:none; } |
| .ltx_bibtag { font-weight:bold; margin-left:-2em; width:3em; } |
| /*.bibitem-tag + div { display:inline; }*/ |
| .ltx_bib_title { font-style:italic; } |
| .ltx_bib_article .bib-title { font-style:normal !important; } |
| .ltx_bib_journal { font-style:italic; } |
| .ltx_bib_volume { font-weight:bold; } |
| |
| /* Indices */ |
| .ltx_indexlist li { list-style-type:none; } |
| .ltx_indexlist { margin-left:1em; padding-left:1em;} |
| |
| /* Listings */ |
| .ltx_listing { |
| display:block; |
| margin: 1ex 3em 1ex 3em; |
| overflow-x:auto; } |
| .ltx_float .ltx_listing { |
| margin: 0; } |
| .ltx_listingline { white-space:nowrap; min-height:1em; } |
| .ltx_lst_numbers_left .ltx_listingline .ltx_tag { |
| background-color:transparent; |
| margin-left:-3em; width:2.5em; |
| position:absolute; |
| text-align:right; } |
| .ltx_lst_numbers_right .ltx_listingline .ltx_tag { |
| background-color:transparent; |
| width:2.5em; |
| position:absolute; right:3em; |
| text-align:right; } |
| /* |
| position:absolute; left:0em; |
| max-width:0em; text-align:right; } |
| */ |
| .ltx_parbox {text-indent:0em; } |
| |
| /* NOTE that it is CRITICAL to put position:relative outside & absolute inside!! |
| I wish I understood why! |
| Outer box establishes resulting size, neutralizes any outer positioning, etc; |
| inner establishes position of stuff to be rotated */ |
| .ltx_transformed_outer { |
| position:relative; bottom:0pt;left:0pt; |
| overflow:visible; } |
| .ltx_transformed_inner { |
| display:block; |
| position:absolute;bottom:0pt;left:0pt; } |
| .ltx_transformed_inner > .ltx_p {text-indent:0em; margin:0; padding:0; } |
| /* If simulating a table (html5), try to get rowspan to work...sorta? */ |
| span.ltx_rowspan { position:absolute; top:0; bottom:0; } |
| |
| /* by default, p doesn't indent */ |
| .ltx_p { text-indent:0em; white-space:normal; } |
| /* explicit control of indentation (on ltx_para) */ |
| .ltx_indent > .ltx_p:first-child { text-indent:2em!important; } |
| .ltx_noindent > .ltx_p:first-child { text-indent:0em!important; } |
| |
| /*====================================================================== |
| Columns */ |
| .ltx_page_column1 { |
| width:44%; float:left; } /* IE uses % of wrong container*/ |
| .ltx_page_column2 { |
| width:44%; float:right; } |
| .ltx_page_columns > .ltx_page_column1 { |
| width:48%; float:left; } |
| .ltx_page_columns > .ltx_page_column2 { |
| width:48%; float:right; } |
| .ltx_page_columns:after { |
| content:"."; display:block; height:0; clear:both; visibility:hidden; } |
| |
| /*====================================================================== |
| Borders and such */ |
| .ltx_tabular { display:inline-table; border-collapse:collapse; } |
| .ltx_tabular.ltx_centering { display:table; } |
| .ltx_thead, |
| .ltx_tfoot, |
| .ltx_tbody { display:table-row-group; } |
| .ltx_tr { display:table-row; } |
| .ltx_td, |
| .ltx_th { display:table-cell; } |
| |
| .ltx_framed { border:1px solid black;} |
| .ltx_tabular .ltx_td, |
| .ltx_tabular .ltx_th { padding:0.1em 0.5em; } |
| /* regular lines */ |
| .ltx_border_t { border-top:1px solid black; } |
| .ltx_border_r { border-right:1px solid black; } |
| .ltx_border_b { border-bottom:1px solid black; } |
| .ltx_border_l { border-left:1px solid black; } |
| /* double lines */ |
| .ltx_border_tt { border-top:3px double black; } |
| .ltx_border_rr { border-right:3px double black; } |
| .ltx_border_bb { border-bottom:3px double black; } |
| .ltx_border_ll { border-left:3px double black; } |
| /* Light lines */ |
| .ltx_border_T { border-top:1px solid gray; } |
| .ltx_border_R { border-right:1px solid gray; } |
| .ltx_border_B { border-bottom:1px solid gray; } |
| .ltx_border_L { border-left:1px solid gray; } |
| /* Framing */ |
| .ltx_framed_rectangle { border-style:solid; border-width:1px; } |
| .ltx_framed_top { border-top-style:solid; border-top-width:1px; } |
| .ltx_framed_left { border-left-style:solid; border-left-width:1px; } |
| .ltx_framed_right { border-right-style:solid; border-right-width:1px; } |
| .ltx_framed_bottom, |
| .ltx_framed_underline { border-bottom-style:solid; border-bottom-width:1px; } |
| .ltx_framed_topbottom { border-top-style:solid; border-top-width:1px; |
| border-bottom-style:solid; border-bottom-width:1px; } |
| .ltx_framed_leftright { border-left-style:solid; border-left-width:1px; |
| border-right-style:solid; border-right-width:1px; } |
| |
| /*====================================================================== |
| Misc */ |
| /* .ltx_verbatim*/ |
| .ltx_verbatim { text-align:left; } |
| /*====================================================================== |
| Meta stuff, footnotes */ |
| .ltx_note_content { display:none; } |
| /*right:5%; */ |
| .ltx_note_content { |
| max-width: 70%; font-size:90%; left:15%; |
| text-align:left; |
| background-color: white; |
| padding: 0.5em 1em 0.5em 1.5em; |
| border: 1px solid black; border-radius: 0 5px 5px 5px; box-shadow: 5px 5px 10px gray; } |
| .ltx_note_mark { color:blue; } |
| .ltx_note_type { font-weight: bold; } |
| .ltx_note { display:inline-block; text-indent:0; } /* So we establish containing block */ |
| .ltx_note_content .ltx_note_mark { position:absolute; left:0.2em; top:-0.1em; } |
| .ltx_note:hover .ltx_note_content, |
| .ltx_note .ltx_note_content:hover { |
| display:block; position:absolute; z-index:10; } |
| |
| .ltx_ERROR { color:red; } |
| .ltx_rdf { display:none; } |
| .ltx_missing { color:red;} |
| .ltx_nounicode { color:red; } |
| /*====================================================================== |
| SVG (pgf/tikz ?) basics */ |
| |
| /* Stuff appearing in svg:foreignObject */ |
| .ltx_svg_fog foreignObject { margin:0; padding:0; overflow:visible; } |
| .ltx_svg_fog foreignObject > p { margin:0; padding:0; display:block; } |
| /*.ltx_svg_fog foreignObject > p { margin:0; padding:0; display:block; white-space:nowrap; }*/ |
| |
| /*====================================================================== |
| Low-level Basics */ |
| /* Note that LaTeX(ML)'s font model doesn't map quite exactly to CSS's */ |
| /* Font Families => font-family */ |
| .ltx_font_serif { font-family: serif; } |
| .ltx_font_sansserif { font-family: sans-serif; } |
| .ltx_font_typewriter { font-family: monospace; } |
| /* dingbats should be converted to unicode? */ |
| /* Math font families handled within math: script, symbol, fraktur, blackboard ? */ |
| /* Font Series => font-weight */ |
| .ltx_font_bold { font-weight: bold; } |
| .ltx_font_medium { font-weight: normal; } |
| /* Font Shapes => font-style or font-variant */ |
| .ltx_font_italic { font-style: italic; font-variant:normal; } |
| .ltx_font_upright { font-style: normal; font-variant:normal; } |
| .ltx_font_slanted { font-style: oblique; font-variant:normal; } |
| .ltx_font_smallcaps { font-variant: small-caps; font-style:normal; } |
| .ltx_font_oldstyle { font-variant: oldstyle-nums; /* experimental css3 ? Doesn't seem to work!*/ |
| font-style:normal; |
| -moz-font-feature-settings: "onum"; |
| -ms-font-feature-settings: "onum"; |
| -webkit-font-feature-settings: "onum"; |
| font-variant-numeric: oldstyle-nums; } |
| .ltx_font_mathcaligraphic { font-family: "Lucida Calligraphy", "Zapf Chancery","URW Chancery L"; } |
| /* |
| |
| .ltx_font_mathscript { ? } |
| */ |
| cite { font-style: normal; } |
| |
| .ltx_red { color:red; } |
| /*.ltx_centering { text-align:center; margin:auto; }*/ |
| /*.ltx_inline-block.ltx_centering,*/ |
| /* Hmm.... is this right in general? */ |
| .ltx_centering { display:block; margin:auto; text-align:center; } |
| |
| /* Dubious stuff */ |
| .ltx_hflipped { |
| display:inline-block; |
| -moz-transform: scaleX(-1); |
| -o-transform: scaleX(-1); |
| -webkit-transform: scaleX(-1); |
| transform: scaleX(-1); |
| filter: FlipH; |
| -ms-fliter: "FlipH"; } |
| .ltx_vflipped { |
| display:inline-block; |
| -moz-transform: scaleY(-1); |
| -o-transform: scaleY(-1); |
| -webkit-transform: scaleY(-1); |
| transform: scaleY(-1); |
| filter: FlipV; |
| -ms-fliter: "FlipV"; } |
| |
| /* .ltx_phantom handled in xslt */ |
| |
| |
| </style> |
| |
| <!-- autoinlined `/tmp/docs/tutorial/html/ltx-report.css' --> |
| <style type='text/css'> |
| |
| .ltx_title_document { font-size:170%; text-align:center; margin:1em 0 1em 0; } |
| .ltx_authors, |
| .ltx_role_author { text-align:center; margin:1em 0 1em 0; } |
| .ltx_role_author .ltx_personname { font-size: 120%; } |
| .ltx_date { text-align:center; font-size: 120%; margin:1em 0 1em 0; } |
| .ltx_subtitle { text-align:center; font-size: 120%; padding-left:0.2em; margin-left:-0.5em; } |
| |
| .ltx_title_abstract { text-align:center; font-size: 100%; font-weight:bold; } |
| .ltx_abstract { margin-left:4em; margin-right:4em; } |
| |
| .ltx_appendix, |
| .ltx_part, |
| .ltx_chapter, |
| .ltx_section, |
| .ltx_subsection, |
| .ltx_subsubsection { margin-top:1.5em; } |
| .ltx_paragraph, |
| .ltx_subparagraph { margin-top:1.0em; } |
| |
| .ltx_title_part { font-size:200%; font-weight:bold; margin-bottom:1em; } |
| .ltx_title_appendix, |
| .ltx_title_chapter { font-size:200%; font-weight:bold; margin-bottom:1em; } |
| .ltx_title_chapter .ltx_tag { display:block; font-size:90%; margin-bottom:0.5em; } |
| .ltx_title_section { font-size:140%; font-weight:bold; margin-bottom:1em; } |
| .ltx_title_subsection { font-size:120%; font-weight:bold; margin-bottom:1em; } |
| .ltx_title_subsubsection { font-size:100%; font-weight:bold; margin-bottom:1em; } |
| |
| /* Paragraph & Subparagraph titles should be runin! */ |
| .ltx_title_paragraph { font-size:100%; font-weight:bold; display:inline; |
| margin-right:1em; } |
| .ltx_paragraph .ltx_title, |
| .ltx_paragraph .ltx_title + .ltx_para, |
| .ltx_paragraph .ltx_title + .ltx_para > .ltx_p { display:inline; } |
| |
| .ltx_title_subparagraph { font-size:100%; font-weight:bold; display:inline; |
| margin-left:2em; margin-right:1em; } |
| .ltx_subparagraph .ltx_title, |
| .ltx_subparagraph .ltx_title + .ltx_para, |
| .ltx_subparagraph .ltx_title + .ltx_para > .ltx_p { display:inline; } |
| |
| .ltx_figure { text-align:center; margin:auto; margin:0.5em; } |
| .ltx_table { text-align:center; margin:auto; margin:0.5em; } |
| |
| /* experimental: flex model, to center short captions, justify long ones */ |
| .ltx_table, |
| .ltx_figure { display:flex; flex-direction:column; align-items:center; } |
| .ltx_table .ltx_caption, |
| .ltx_figure .ltx_caption { text-align:justify; } |
| |
| /* first p in para gets indented */ |
| .ltx_para > .ltx_p:first-child { text-indent:2em; } |
| /* except the initial in a section */ |
| section > .ltx_title +.ltx_para > .ltx_p, |
| section > .ltx_title +.ltx_date +.ltx_para > .ltx_p {text-indent:0em; } |
| |
| .ltx_itemize { margin-left:1em; } |
| |
| .ltx_theorem { margin-top:0.5em; margin-bottom:0.5em; } |
| .ltx_theorem .ltx_title { margin-bottom:0.1em; font-weight:normal; } |
| .ltx_theorem .ltx_title + .ltx_para, |
| .ltx_theorem .ltx_title + .ltx_para .ltx_p, |
| .ltx_theorem .ltx_title + .ltx_p { margin-top:0em; } |
| |
| </style> |
| |
| <!-- autoinlined `/tmp/docs/tutorial/html/ltx-listings.css' --> |
| <style type='text/css'> |
| |
| .ltx_listing_data { |
| float:right; } |
| .ltx_listing_data a { |
| text-decoration:none; } |
| </style> |
| |
| <link rel='stylesheet' href='http://www.sac-home.org/lib/tpl/bootstrap3/assets/bootstrap/journal/bootstrap.min.css' type='text/css'> |
| <!-- autoinlined `/tmp/docs/tutorial/html/tutorial.css' --> |
| <style type='text/css'> |
| /*body { |
| padding-top: 1em; |
| max-width: 50em; |
| margin: auto; |
| }*/ |
| |
| /* This section converts inline menu div into a floating menu. */ |
| .ltx_role_contents { |
| width: 300px; |
| margin-left: 0px; |
| overflow-y: auto; |
| max-height: 90%; |
| /*padding-top: 15px;*/ |
| /*border-right: 1px solid black;*/ |
| float: left; |
| clear: left; |
| top: 0; |
| position: fixed; |
| margin-top: 85px; |
| padding-right: 5px; |
| } |
| |
| .ltx_page_main { |
| margin-top: -30px; |
| padding: 0; |
| } |
| |
| .ltx_titlepage { |
| padding-left: 320px; |
| } |
| |
| .ltx_part { |
| padding-left: 320px; |
| } |
| |
| .ltx_role_contents h6 { |
| display: none; |
| } |
| |
| .ltx_role_contents > ul { |
| padding: 0; |
| } |
| |
| .ltx_page_footer { |
| display: none; |
| } |
| /* end of floating-menu-related definitions. */ |
| |
| /* This places captions of the code snippets behind the snippet. |
| XXX This is a hack as currently LateXML gets confused when |
| position of a caption (as specified by lstset in tex) is |
| bottom. Therefore, we keep tex definition on top and |
| fix it via CSS. |
| |
| XXX I am not sure that changing display to 'table' is a good |
| idea, but I don't know any other way on how to move the |
| caption down. */ |
| figure { |
| display: table; |
| width: 95%; |
| } |
| figcaption { |
| display: table-caption; |
| caption-side: bottom; |
| } |
| |
| /* We don't need paragraph indentation in html. */ |
| .ltx_para > .ltx_p:first-child { text-indent:0em; } |
| |
| |
| /* This minheight needs to be adjusted to the bootstrap |
| minimum height so that the line numbers in listings |
| behave correctly. */ |
| .ltx_listingline { |
| white-space:nowrap; |
| min-height:1.42857143em; |
| } |
| |
| /* Get rid of italic inside the theorem environment. |
| This has an effect on the way excersises look. */ |
| .ltx_theorem_theorem .ltx_font_italic { |
| font-style: normal; |
| } |
| |
| .ltx_theorem_theorem { |
| border-left: 7px solid #ccc; |
| /*padding: 2px 4px;*/ |
| padding-left: 10px; |
| margin-left: 3em; |
| } |
| |
| .ltx_theorem_theorem h6 { |
| /*color: #333;*/ |
| font-weight: normal; |
| } |
| |
| .ltx_listing { |
| /* A combination of pre and code. */ |
| font-family: Menlo, Monaco, Consolas, "Courier New", monospace; |
| padding: 2px 4px; |
| font-size: 90%; |
| border-radius: 4px; |
| display: block; |
| line-height: 1.42857143; |
| word-break: break-all; |
| word-wrap: break-word; |
| color: #333333; |
| background-color: #f5f5f5; |
| border: 1px solid #cccccc; |
| } |
| |
| .ltx_caption { |
| padding-top: 8px; |
| padding-bottom: 8px; |
| color: #999999; |
| text-align: center; |
| } |
| |
| .ltx_framed_rectangle { |
| text-align: left; |
| border: 1px solid #cccccc; |
| font-size: 90%; |
| border-radius: 4px; |
| padding: 2px 4px; |
| } |
| |
| .ltx_theorem_theorem { |
| font-style: normal important!; |
| } |
| /*.ltx_framed_rectangle { |
| float: left; |
| width: 20em; |
| margin-right: 10px; |
| margin-left: -10em; |
| }*/ |
| |
| </style> |
| |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<link rel="stylesheet" href="LaTeXML.css" type="text/css"> | |
<link rel="stylesheet" href="ltx-report.css" type="text/css"> | |
<link rel="stylesheet" href="ltx-listings.css" type="text/css"> | |
<link rel="stylesheet" href="http://www.sac-home.org/dokuwiki/lib/tpl/bootstrap3/assets/bootstrap/journal/bootstrap.min.css" type="text/css"> | |
<link rel="stylesheet" href="tutorial.css" type="text/css"> | |
</head> | </head> |
<body> | <body> |
<div class="ltx_page_main"> | <div class='ltx_page_main'> |
<div class="ltx_page_content"> | <div class='ltx_page_content'> |
<article class="ltx_document"> | <article class='ltx_document'> |
<div class="ltx_titlepage"> | <div class='ltx_titlepage'> |
<p class="ltx_p"><span class="ltx_text" style="font-size:298%;">SINGLE ASSIGNMENT C | <p class='ltx_p'><span class='ltx_text' style='font-size:298%;'>SINGLE ASSIGNMENT C |
<br class="ltx_break"></span> | <br class='ltx_break'></span> |
<span class="ltx_text" style="font-size:298%;">TUTORIAL | <span class='ltx_text' style='font-size:298%;'>TUTORIAL |
<br class="ltx_break"></span> | <br class='ltx_break'></span> |
<span class="ltx_text" style="font-size:144%;">VERSION 1.2</span></p> | <span class='ltx_text' style='font-size:144%;'>VERSION 1.2</span></p> |
<p class="ltx_p"><span class="ltx_text ltx_font_smallcaps" style="font-size:144%;">Sven-Bodo Scholz<span class="ltx_text ltx_font_upright"> </span>Stephan Herhut | <p class='ltx_p'><span class='ltx_text ltx_font_smallcaps' style='font-size:144%;'>Sven-Bodo Scholz<span class='ltx_text ltx_font_upright'> </span>Stephan Herhut |
<br class="ltx_break">Frank Penczek<span class="ltx_text ltx_font_upright"> </span>Clemens Grelck | <br class='ltx_break'>Frank Penczek<span class='ltx_text ltx_font_upright'> </span>Clemens Grelck |
<br class="ltx_break">Artem Shinkarov | <br class='ltx_break'>Artem Shinkarov |
<br class="ltx_break"></span></p> | <br class='ltx_break'></span></p> |
<p class="ltx_p"><span class="ltx_text ltx_font_smallcaps" style="font-size:120%;">November 30, 2016</span></p> | <p class='ltx_p'><span class='ltx_text ltx_font_smallcaps' style='font-size:120%;'>March 24, 2017</span></p> |
</div> | </div> |
<div class="ltx_TOC ltx_role_contents"> | <div class='ltx_TOC ltx_role_contents'> |
<h6>Contents:</h6> | <h6>Contents:</h6> |
<ul class="ltx_toclist"> | <ul class='ltx_toclist'> |
<li class="ltx_tocentry ltx_tocentry_part"> | <li class='ltx_tocentry ltx_tocentry_part'> |
<a href="#Pt1" title="Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">I </span>Trails Covering the Basics of SaC</span></a> | <a href='#Pt1' title='Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>I </span>Trails Covering the Basics of SaC</span></a> |
<ul class="ltx_toclist ltx_toclist_part"> | <ul class='ltx_toclist ltx_toclist_part'> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch1" title="Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">1 </span>Running the first program</span></a> | <a href='#Ch1' title='Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>1 </span>Running the first program</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch1.S1" title="1.1 A Checklist ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">1.1 </span>A Checklist</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch1.S1' title='1.1 A Checklist ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>1.1 </span>A Checklist</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch1.S2" title="1.2 Create your first SaC Source File ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">1.2 </span>Create your first <span class="ltx_text ltx_font_smallcaps">SaC</span> Source File</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch1.S2' title='1.2 Create your first SaC Source File ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>1.2 </span>Create your first <span class='ltx_text ltx_font_smallcaps'>SaC</span> Source File</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch1.S3" title="1.3 Compile the Source File and Run the Program ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">1.3 </span>Compile the Source File and Run the Program</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch1.S3' title='1.3 Compile the Source File and Run the Program ‣ Chapter 1 Running the first program ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>1.3 </span>Compile the Source File and Run the Program</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch2" title="Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2 </span>Array Programming Basics</span></a> | <a href='#Ch2' title='Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2 </span>Array Programming Basics</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch2.S1" title="2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.1 </span>Lesson 1: Arrays as Data</span></a> | <a href='#Ch2.S1' title='2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.1 </span>Lesson 1: Arrays as Data</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch2.S1.SS1" title="2.1.1 Defining Arrays ‣ 2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.1.1 </span>Defining Arrays</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch2.S1.SS1' title='2.1.1 Defining Arrays ‣ 2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.1.1 </span>Defining Arrays</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch2.S1.SS2" title="2.1.2 Arrays and Variables ‣ 2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.1.2 </span>Arrays and Variables</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch2.S1.SS2' title='2.1.2 Arrays and Variables ‣ 2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.1.2 </span>Arrays and Variables</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch2.S2" title="2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.2 </span>Lesson 2: Shape-Invariant Programming</span></a> | <a href='#Ch2.S2' title='2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.2 </span>Lesson 2: Shape-Invariant Programming</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch2.S2.SS1" title="2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.2.1 </span>Standard Array Operations</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch2.S2.SS1' title='2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.2.1 </span>Standard Array Operations</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch2.S2.SS2" title="2.2.2 Axis Control Notation ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.2.2 </span>Axis Control Notation</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch2.S2.SS2' title='2.2.2 Axis Control Notation ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.2.2 </span>Axis Control Notation</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch2.S2.SS3" title="2.2.3 Putting it all Together ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">2.2.3 </span>Putting it all Together</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch2.S2.SS3' title='2.2.3 Putting it all Together ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>2.2.3 </span>Putting it all Together</span></a></li> |
</ul> | </ul> |
</li> | </li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch3" title="Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3 </span>Basic Program Structure</span></a> | <a href='#Ch3' title='Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3 </span>Basic Program Structure</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch3.S1" title="3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.1 </span>Lesson 3: Functions and their Types</span></a> | <a href='#Ch3.S1' title='3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.1 </span>Lesson 3: Functions and their Types</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S1.SS1" title="3.1.1 Function Definitions ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.1.1 </span>Function Definitions</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S1.SS1' title='3.1.1 Function Definitions ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.1.1 </span>Function Definitions</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S1.SS2" title="3.1.2 Built-in Types ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.1.2 </span>Built-in Types</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S1.SS2' title='3.1.2 Built-in Types ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.1.2 </span>Built-in Types</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S1.SS3" title="3.1.3 Subtyping ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.1.3 </span>Subtyping</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S1.SS3' title='3.1.3 Subtyping ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.1.3 </span>Subtyping</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S1.SS4" title="3.1.4 Function Overloading ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.1.4 </span>Function Overloading</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S1.SS4' title='3.1.4 Function Overloading ‣ 3.1 Lesson 3: Functions and their Types ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.1.4 </span>Function Overloading</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch3.S2" title="3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2 </span>Lesson 4: Function Bodies</span></a> | <a href='#Ch3.S2' title='3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2 </span>Lesson 4: Function Bodies</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S2.SS1" title="3.2.1 Variable Declarations ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2.1 </span>Variable Declarations</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S2.SS1' title='3.2.1 Variable Declarations ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2.1 </span>Variable Declarations</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S2.SS2" title="3.2.2 Assignments ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2.2 </span>Assignments</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S2.SS2' title='3.2.2 Assignments ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2.2 </span>Assignments</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S2.SS3" title="3.2.3 Conditionals ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2.3 </span>Conditionals</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S2.SS3' title='3.2.3 Conditionals ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2.3 </span>Conditionals</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S2.SS4" title="3.2.4 Loops ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2.4 </span>Loops</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S2.SS4' title='3.2.4 Loops ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2.4 </span>Loops</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S2.SS5" title="3.2.5 Explicit Control Flow Manipulation ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.2.5 </span>Explicit Control Flow Manipulation</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S2.SS5' title='3.2.5 Explicit Control Flow Manipulation ‣ 3.2 Lesson 4: Function Bodies ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.2.5 </span>Explicit Control Flow Manipulation</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch3.S3" title="3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.3 </span>Lesson 5: Advanced Topics</span></a> | <a href='#Ch3.S3' title='3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.3 </span>Lesson 5: Advanced Topics</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S3.SS1" title="3.3.1 User-defined Types ‣ 3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.3.1 </span>User-defined Types</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S3.SS1' title='3.3.1 User-defined Types ‣ 3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.3.1 </span>User-defined Types</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch3.S3.SS2" title="3.3.2 Type Conversions ‣ 3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">3.3.2 </span>Type Conversions</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch3.S3.SS2' title='3.3.2 Type Conversions ‣ 3.3 Lesson 5: Advanced Topics ‣ Chapter 3 Basic Program Structure ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>3.3.2 </span>Type Conversions</span></a></li> |
</ul> | </ul> |
</li> | </li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch4" title="Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4 </span>With-Loops</span></a> | <a href='#Ch4' title='Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4 </span>With-Loops</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch4.S1" title="4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4.1 </span>Lesson 6: with-loop Basics</span></a> | <a href='#Ch4.S1' title='4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4.1 </span>Lesson 6: with-loop Basics</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch4.S1.SS1" title="4.1.1 Basic Components ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4.1.1 </span>Basic Components</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch4.S1.SS1' title='4.1.1 Basic Components ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4.1.1 </span>Basic Components</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch4.S1.SS2" title="4.1.2 Generator Ranges ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4.1.2 </span>Generator Ranges</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch4.S1.SS2' title='4.1.2 Generator Ranges ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4.1.2 </span>Generator Ranges</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch4.S1.SS3" title="4.1.3 Generator Expressions ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4.1.3 </span>Generator Expressions</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch4.S1.SS3' title='4.1.3 Generator Expressions ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4.1.3 </span>Generator Expressions</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch4.S1.SS4" title="4.1.4 Reductions and further with-loop Operations ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">4.1.4 </span>Reductions and further with-loop Operations</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch4.S1.SS4' title='4.1.4 Reductions and further with-loop Operations ‣ 4.1 Lesson 6: with-loop Basics ‣ Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>4.1.4 </span>Reductions and further with-loop Operations</span></a></li> |
</ul> | </ul> |
</li> | </li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch5" title="Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5 </span>Working with Modules</span></a> | <a href='#Ch5' title='Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5 </span>Working with Modules</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch5.S1" title="5.1 Name Spaces ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5.1 </span>Name Spaces</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch5.S1' title='5.1 Name Spaces ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5.1 </span>Name Spaces</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch5.S2" title="5.2 Use Statements ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5.2 </span>Use Statements</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch5.S2' title='5.2 Use Statements ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5.2 </span>Use Statements</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch5.S3" title="5.3 Import statement ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5.3 </span>Import statement</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch5.S3' title='5.3 Import statement ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5.3 </span>Import statement</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch5.S4" title="5.4 Putting It Together ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5.4 </span>Putting It Together</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch5.S4' title='5.4 Putting It Together ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5.4 </span>Putting It Together</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch5.S5" title="5.5 Implementing Modules ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">5.5 </span>Implementing Modules</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch5.S5' title='5.5 Implementing Modules ‣ Chapter 5 Working with Modules ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>5.5 </span>Implementing Modules</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch6" title="Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">6 </span>Case Studies</span></a> | <a href='#Ch6' title='Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>6 </span>Case Studies</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch6.S1" title="6.1 Lesson 7: Image Processing ‣ Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">6.1 </span>Lesson 7: Image Processing</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch6.S1' title='6.1 Lesson 7: Image Processing ‣ Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>6.1 </span>Lesson 7: Image Processing</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch6.S2" title="6.2 Lesson 8: Computing Mandelbrot Images ‣ Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">6.2 </span>Lesson 8: Computing Mandelbrot Images</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch6.S2' title='6.2 Lesson 8: Computing Mandelbrot Images ‣ Chapter 6 Case Studies ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>6.2 </span>Lesson 8: Computing Mandelbrot Images</span></a></li> |
</ul> | </ul> |
</li> | </li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_part"> | <li class='ltx_tocentry ltx_tocentry_part'> |
<a href="#Pt2" title="Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">II </span>Trails Covering More Advanced Features of SaC</span></a> | <a href='#Pt2' title='Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>II </span>Trails Covering More Advanced Features of SaC</span></a> |
<ul class="ltx_toclist ltx_toclist_part"> | <ul class='ltx_toclist ltx_toclist_part'> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch7" title="Chapter 7 Treasures in the Standard Library ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">7 </span>Treasures in the Standard Library</span></a> | <a href='#Ch7' title='Chapter 7 Treasures in the Standard Library ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>7 </span>Treasures in the Standard Library</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch7.S1" title="7.1 Lesson: Benchmarking SaC Programs ‣ Chapter 7 Treasures in the Standard Library ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">7.1 </span>Lesson: Benchmarking <span class="ltx_text ltx_font_smallcaps">SaC</span> Programs</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch7.S1' title='7.1 Lesson: Benchmarking SaC Programs ‣ Chapter 7 Treasures in the Standard Library ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>7.1 </span>Lesson: Benchmarking <span class='ltx_text ltx_font_smallcaps'>SaC</span> Programs</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"><a href="#Ch8" title="Chapter 8 User Defined Types ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">8 </span>User Defined Types</span></a></li> | <li class='ltx_tocentry ltx_tocentry_chapter'><a href='#Ch8' title='Chapter 8 User Defined Types ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>8 </span>User Defined Types</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch9" title="Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9 </span>Dealing with I/O and State in General</span></a> | <a href='#Ch9' title='Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9 </span>Dealing with I/O and State in General</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch9.S1" title="9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9.1 </span>Lesson: States and Objects — the basics</span></a> | <a href='#Ch9.S1' title='9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9.1 </span>Lesson: States and Objects — the basics</span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch9.S1.SS1" title="9.1.1 Extending Classes ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9.1.1 </span>Extending Classes</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch9.S1.SS1' title='9.1.1 Extending Classes ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9.1.1 </span>Extending Classes</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch9.S1.SS2" title="9.1.2 States using Classes ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9.1.2 </span>States using Classes</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch9.S1.SS2' title='9.1.2 States using Classes ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9.1.2 </span>States using Classes</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch9.S1.SS3" title="9.1.3 Global Objects ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9.1.3 </span>Global Objects</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch9.S1.SS3' title='9.1.3 Global Objects ‣ 9.1 Lesson: States and Objects — the basics ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9.1.3 </span>Global Objects</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch9.S2" title="9.2 Lesson: Nondeterminism through Shared State in Wihth-Loops ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">9.2 </span>Lesson: Nondeterminism through Shared State in Wihth-Loops</span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch9.S2' title='9.2 Lesson: Nondeterminism through Shared State in Wihth-Loops ‣ Chapter 9 Dealing with I/O and State in General ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>9.2 </span>Lesson: Nondeterminism through Shared State in Wihth-Loops</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_chapter"> | <li class='ltx_tocentry ltx_tocentry_chapter'> |
<a href="#Ch10" title="Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10 </span>Interfacing with Other Languages</span></a> | <a href='#Ch10' title='Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10 </span>Interfacing with Other Languages</span></a> |
<ul class="ltx_toclist ltx_toclist_chapter"> | <ul class='ltx_toclist ltx_toclist_chapter'> |
<li class="ltx_tocentry ltx_tocentry_section"> | <li class='ltx_tocentry ltx_tocentry_section'> |
<a href="#Ch10.S1" title="10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.1 </span>Lesson: Calling <span class="ltx_text ltx_font_smallcaps">C</span> from <span class="ltx_text ltx_font_smallcaps">SaC</span></span></a> | <a href='#Ch10.S1' title='10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.1 </span>Lesson: Calling <span class='ltx_text ltx_font_smallcaps'>C</span> from <span class='ltx_text ltx_font_smallcaps'>SaC</span></span></a> |
<ul class="ltx_toclist ltx_toclist_section"> | <ul class='ltx_toclist ltx_toclist_section'> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch10.S1.SS1" title="10.1.1 Using C in the Small ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.1.1 </span>Using C in Small</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch10.S1.SS1' title='10.1.1 Using C in the Small ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.1.1 </span>Using C in Small</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch10.S1.SS2" title="10.1.2 Stateful C functions ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.1.2 </span>Stateful <span class="ltx_text ltx_font_smallcaps">C</span> functions</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch10.S1.SS2' title='10.1.2 Stateful C functions ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.1.2 </span>Stateful <span class='ltx_text ltx_font_smallcaps'>C</span> functions</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch10.S1.SS3" title="10.1.3 Using pragma directives ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.1.3 </span>Using pragma directives</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch10.S1.SS3' title='10.1.3 Using pragma directives ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.1.3 </span>Using pragma directives</span></a></li> |
<li class="ltx_tocentry ltx_tocentry_subsection"><a href="#Ch10.S1.SS4" title="10.1.4 Example TermFile ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.1.4 </span>Example TermFile</span></a></li> | <li class='ltx_tocentry ltx_tocentry_subsection'><a href='#Ch10.S1.SS4' title='10.1.4 Example TermFile ‣ 10.1 Lesson: Calling C from SaC ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.1.4 </span>Example TermFile</span></a></li> |
</ul> | </ul> |
</li> | </li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch10.S2" title="10.2 Lesson: Using SaC libraries from C ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.2 </span>Lesson: Using <span class="ltx_text ltx_font_smallcaps">SaC</span> libraries from <span class="ltx_text ltx_font_smallcaps">C</span></span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch10.S2' title='10.2 Lesson: Using SaC libraries from C ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.2 </span>Lesson: Using <span class='ltx_text ltx_font_smallcaps'>SaC</span> libraries from <span class='ltx_text ltx_font_smallcaps'>C</span></span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch10.S3" title="10.3 Lesson: Using SaC libraries from C++ ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.3 </span>Lesson: Using <span class="ltx_text ltx_font_smallcaps">SaC</span> libraries from <span class="ltx_text ltx_font_smallcaps">C++</span></span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch10.S3' title='10.3 Lesson: Using SaC libraries from C++ ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.3 </span>Lesson: Using <span class='ltx_text ltx_font_smallcaps'>SaC</span> libraries from <span class='ltx_text ltx_font_smallcaps'>C++</span></span></a></li> |
<li class="ltx_tocentry ltx_tocentry_section"><a href="#Ch10.S4" title="10.4 Lesson: Using SaC libraries from Fortran ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_title"><span class="ltx_tag ltx_tag_ref">10.4 </span>Lesson: Using <span class="ltx_text ltx_font_smallcaps">SaC</span> libraries from <span class="ltx_text ltx_font_smallcaps">Fortran</span></span></a></li> | <li class='ltx_tocentry ltx_tocentry_section'><a href='#Ch10.S4' title='10.4 Lesson: Using SaC libraries from Fortran ‣ Chapter 10 Interfacing with Other Languages ‣ Part II Trails Covering More Advanced Features of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_title'><span class='ltx_tag ltx_tag_ref'>10.4 </span>Lesson: Using <span class='ltx_text ltx_font_smallcaps'>SaC</span> libraries from <span class='ltx_text ltx_font_smallcaps'>Fortran</span></span></a></li> |
</ul> | </ul> |
</li> | </li> |
</ul> | </ul> |
</div> | </div> |
<section id="Pt1" class="ltx_part"> | <section id='Pt1' class='ltx_part'> |
<h2 class="ltx_title ltx_title_part"> | <h2 class='ltx_title ltx_title_part'> |
<span class="ltx_tag ltx_tag_part">Part I </span>Trails Covering the Basics of <span class="ltx_text ltx_font_smallcaps">SaC</span> | <span class='ltx_tag ltx_tag_part'>Part I </span>Trails Covering the Basics of <span class='ltx_text ltx_font_smallcaps'>SaC</span> |
</h2> | </h2> |
| |
<section id="Ch1" class="ltx_chapter"> | <section id='Ch1' class='ltx_chapter'> |
<h3 class="ltx_title ltx_title_chapter"> | <h3 class='ltx_title ltx_title_chapter'> |
<span class="ltx_tag ltx_tag_chapter">Chapter 1 </span>Running the first program</h3> | <span class='ltx_tag ltx_tag_chapter'>Chapter 1 </span>Running the first program</h3> |
| |
<div id="Ch1.p1" class="ltx_para"> | <div id='Ch1.p1' class='ltx_para'> |
<p class="ltx_p">The following instructions will help you write your first <span class="ltx_text ltx_font_smallcaps">SaC</span> program.</p> | <p class='ltx_p'>The following instructions will help you write your first <span class='ltx_text ltx_font_smallcaps'>SaC</span> program.</p> |
</div> | </div> |
<section id="Ch1.S1" class="ltx_section"> | <section id='Ch1.S1' class='ltx_section'> |
<h4 class="ltx_title ltx_title_section"> | <h4 class='ltx_title ltx_title_section'> |
<span class="ltx_tag ltx_tag_section">1.1 </span>A Checklist</h4> | <span class='ltx_tag ltx_tag_section'>1.1 </span>A Checklist</h4> |
| |
<div id="Ch1.S1.p1" class="ltx_para"> | <div id='Ch1.S1.p1' class='ltx_para'> |
<p class="ltx_p">To successfully write and run your first <span class="ltx_text ltx_font_smallcaps">SaC</span> program, you will need:</p> | <p class='ltx_p'>To successfully write and run your first <span class='ltx_text ltx_font_smallcaps'>SaC</span> program, you will need:</p> |
<ul id="Ch1.I1" class="ltx_itemize"> | <ul id='Ch1.I1' class='ltx_itemize'> |
<li id="Ch1.I1.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch1.I1.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch1.I1.i1.p1" class="ltx_para"> | <div id='Ch1.I1.i1.p1' class='ltx_para'> |
<p class="ltx_p">An <span class="ltx_text ltx_font_bold">ANSI C compiler</span>, such as <span class="ltx_text ltx_font_typewriter">gcc</span>. Though not needed directly, | <p class='ltx_p'>An <span class='ltx_text ltx_font_bold'>ANSI C compiler</span>, such as <span class='ltx_text ltx_font_typewriter'>gcc</span>. Though not needed directly, |
the <span class="ltx_text ltx_font_smallcaps">SaC</span> compiler relies on it.</p> | the <span class='ltx_text ltx_font_smallcaps'>SaC</span> compiler relies on it.</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch1.I1.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch1.I1.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch1.I1.i2.p1" class="ltx_para"> | <div id='Ch1.I1.i2.p1' class='ltx_para'> |
<p class="ltx_p">The <span class="ltx_text ltx_font_bold">SaC compiler</span> <span class="ltx_text ltx_font_typewriter">sac2c</span>. It can be downloaded at | <p class='ltx_p'>The <span class='ltx_text ltx_font_bold'>SaC compiler</span> <span class='ltx_text ltx_font_typewriter'>sac2c</span>. It can be downloaded at |
<a href="http://www.sac-home.org" title="" class="ltx_ref ltx_url ltx_font_typewriter">http://www.sac-home.org</a>; see instructions in the Download | <a href='http://www.sac-home.org' title='' class='ltx_ref ltx_url ltx_font_typewriter'>http://www.sac-home.org</a>; see instructions in the Download |
section.</p> | section.</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch1.I1.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch1.I1.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch1.I1.i3.p1" class="ltx_para"> | <div id='Ch1.I1.i3.p1' class='ltx_para'> |
<p class="ltx_p">The <span class="ltx_text ltx_font_bold">SaC standard library</span> can be downloaded from GitHub | <p class='ltx_p'>The <span class='ltx_text ltx_font_bold'>SaC standard library</span> can be downloaded from GitHub |
<a href="http://www.github.com/SacBase/stdlib-core" title="" class="ltx_ref ltx_url ltx_font_typewriter">http://www.github.com/SacBase/stdlib-core</a>. The process | <a href='http://www.github.com/SacBase/stdlib-core' title='' class='ltx_ref ltx_url ltx_font_typewriter'>http://www.github.com/SacBase/stdlib-core</a>. The process |
of installation is described in README.md file of the stdlib | of installation is described in README.md file of the stdlib |
repository.</p> | repository.</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch1.I1.i4" class="ltx_item" style="list-style-type:none;"> | <li id='Ch1.I1.i4' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch1.I1.i4.p1" class="ltx_para"> | <div id='Ch1.I1.i4.p1' class='ltx_para'> |
<p class="ltx_p">Your favorite <span class="ltx_text ltx_font_bold">text editor</span>, such as <span class="ltx_text ltx_font_typewriter">vi</span> or <span class="ltx_text ltx_font_typewriter">emacs</span>.</p> | <p class='ltx_p'>Your favorite <span class='ltx_text ltx_font_bold'>text editor</span>, such as <span class='ltx_text ltx_font_typewriter'>vi</span> or <span class='ltx_text ltx_font_typewriter'>emacs</span>.</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</section> | </section> |
<section id="Ch1.S2" class="ltx_section"> | <section id='Ch1.S2' class='ltx_section'> |
<h4 class="ltx_title ltx_title_section"> | <h4 class='ltx_title ltx_title_section'> |
<span class="ltx_tag ltx_tag_section">1.2 </span>Create your first <span class="ltx_text ltx_font_smallcaps">SaC</span> Source File</h4> | <span class='ltx_tag ltx_tag_section'>1.2 </span>Create your first <span class='ltx_text ltx_font_smallcaps'>SaC</span> Source File</h4> |
| |
<div id="Ch1.S2.p1" class="ltx_para"> | <div id='Ch1.S2.p1' class='ltx_para'> |
<p class="ltx_p">Start your editor and type the following program:</p> | <p class='ltx_p'>Start your editor and type the following program:</p> |
</div> | </div> |
<figure id="LST1" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST1' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 1: </span>Hello World</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 1: </span>Hello World</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnRmKCJI%0AZWxsbyBXb3JsZCFcbiIpOwogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnRmKCJI%0AZWxsbyBXb3JsZCFcbiIpOwogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">printf</span>(<span class="ltx_text ltx_lst_string">”Hello<span class="ltx_text ltx_lst_space"> </span>World!\n”</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>printf</span>(<span class='ltx_text ltx_lst_string'>”Hello<span class='ltx_text ltx_lst_space'> </span>World!\n”</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch1.S2.p2" class="ltx_para"> | <div id='Ch1.S2.p2' class='ltx_para'> |
<p class="ltx_p">As you can see, it has a strong resemblance to C. The major difference | <p class='ltx_p'>As you can see, it has a strong resemblance to C. The major difference |
are the module use declarations at the beginning of the program. | are the module use declarations at the beginning of the program. |
For now, it suffices to keep in mind, that these two use declarations for most | For now, it suffices to keep in mind, that these two use declarations for most |
experiments will do the job.</p> | experiments will do the job.</p> |
</div> | </div> |
<div id="Ch1.S2.p3" class="ltx_para"> | <div id='Ch1.S2.p3' class='ltx_para'> |
<p class="ltx_p">In order to proceed, save this program into a file named <span class="ltx_text ltx_font_typewriter">world.sac</span>.</p> | <p class='ltx_p'>In order to proceed, save this program into a file named <span class='ltx_text ltx_font_typewriter'>world.sac</span>.</p> |
</div> | </div> |
</section> | </section> |
<section id="Ch1.S3" class="ltx_section"> | <section id='Ch1.S3' class='ltx_section'> |
<h4 class="ltx_title ltx_title_section"> | <h4 class='ltx_title ltx_title_section'> |
<span class="ltx_tag ltx_tag_section">1.3 </span>Compile the Source File and Run the Program</h4> | <span class='ltx_tag ltx_tag_section'>1.3 </span>Compile the Source File and Run the Program</h4> |
| |
<div id="Ch1.S3.p1" class="ltx_para"> | <div id='Ch1.S3.p1' class='ltx_para'> |
<p class="ltx_p">The <span class="ltx_text ltx_font_smallcaps">SaC</span> compiler invocation is similar to the standard invocation of | <p class='ltx_p'>The <span class='ltx_text ltx_font_smallcaps'>SaC</span> compiler invocation is similar to the standard invocation of |
<span class="ltx_text ltx_font_smallcaps">C</span> compilers. | <span class='ltx_text ltx_font_smallcaps'>C</span> compilers. |
A typical shell session for compiling <span class="ltx_text ltx_font_typewriter">world.sac</span> could be:</p> | A typical shell session for compiling <span class='ltx_text ltx_font_typewriter'>world.sac</span> could be:</p> |
</div> | </div> |
<figure id="LST2" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST2' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 2: </span>Typical shell session</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 2: </span>Typical shell session</figcaption> |
<div class="ltx_listing ltx_lst_language_bash ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_bash ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,JCBjZCAvaG9tZS9zYnMvc2FjLwokIGxzCndvcmxkLnNhYwokIHNhYzJjICB3b3JsZC5zYWMKJCBs%0AcwphLm91dCAgICAgIGEub3V0LmMgICAgd29ybGQuc2FjCiQgYS5vdXQKSGVsbG8gV29ybGQh%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,JCBjZCAvaG9tZS9zYnMvc2FjLwokIGxzCndvcmxkLnNhYwokIHNhYzJjICB3b3JsZC5zYWMKJCBs%0AcwphLm91dCAgICAgIGEub3V0LmMgICAgd29ybGQuc2FjCiQgYS5vdXQKSGVsbG8gV29ybGQh%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">$</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">cd</span><span class="ltx_text ltx_lst_space"> </span>/<span class="ltx_text ltx_lst_identifier">home</span>/<span class="ltx_text ltx_lst_identifier">sbs</span>/<span class="ltx_text ltx_lst_identifier">sac</span>/ | <span class='ltx_text ltx_lst_identifier'>$</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>cd</span><span class='ltx_text ltx_lst_space'> </span>/<span class='ltx_text ltx_lst_identifier'>home</span>/<span class='ltx_text ltx_lst_identifier'>sbs</span>/<span class='ltx_text ltx_lst_identifier'>sac</span>/ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">$</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">ls</span> | <span class='ltx_text ltx_lst_identifier'>$</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>ls</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">world</span>.<span class="ltx_text ltx_lst_identifier">sac</span> | <span class='ltx_text ltx_lst_identifier'>world</span>.<span class='ltx_text ltx_lst_identifier'>sac</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">$</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sac2c</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">world</span>.<span class="ltx_text ltx_lst_identifier">sac</span> | <span class='ltx_text ltx_lst_identifier'>$</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sac2c</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>world</span>.<span class='ltx_text ltx_lst_identifier'>sac</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">$</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">ls</span> | <span class='ltx_text ltx_lst_identifier'>$</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>ls</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">a</span>.<span class="ltx_text ltx_lst_identifier">out</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>.<span class="ltx_text ltx_lst_identifier">out</span>.<span class="ltx_text ltx_lst_identifier">c</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">world</span>.<span class="ltx_text ltx_lst_identifier">sac</span> | <span class='ltx_text ltx_lst_identifier'>a</span>.<span class='ltx_text ltx_lst_identifier'>out</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>.<span class='ltx_text ltx_lst_identifier'>out</span>.<span class='ltx_text ltx_lst_identifier'>c</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>world</span>.<span class='ltx_text ltx_lst_identifier'>sac</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">$</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>.<span class="ltx_text ltx_lst_identifier">out</span> | <span class='ltx_text ltx_lst_identifier'>$</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>.<span class='ltx_text ltx_lst_identifier'>out</span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_text ltx_lst_identifier">Hello</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">World</span>! | <span class='ltx_text ltx_lst_identifier'>Hello</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>World</span>! |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch1.S3.p2" class="ltx_para"> | <div id='Ch1.S3.p2' class='ltx_para'> |
<p class="ltx_p">The compilation process consists of two steps. | <p class='ltx_p'>The compilation process consists of two steps. |
First, the <span class="ltx_text ltx_font_smallcaps">SaC</span> compiler generates a <span class="ltx_text ltx_font_smallcaps">C</span> file, which then is compiled | First, the <span class='ltx_text ltx_font_smallcaps'>SaC</span> compiler generates a <span class='ltx_text ltx_font_smallcaps'>C</span> file, which then is compiled |
into target code by utilizing the system’s <span class="ltx_text ltx_font_smallcaps">C</span> compiler. | into target code by utilizing the system’s <span class='ltx_text ltx_font_smallcaps'>C</span> compiler. |
If no target file name is specified, the intermediate <span class="ltx_text ltx_font_smallcaps">C</span> file is named | If no target file name is specified, the intermediate <span class='ltx_text ltx_font_smallcaps'>C</span> file is named |
<span class="ltx_text ltx_font_typewriter">a.out.c</span> so that the subsequent invocation of the <span class="ltx_text ltx_font_smallcaps">C</span> compiler | <span class='ltx_text ltx_font_typewriter'>a.out.c</span> so that the subsequent invocation of the <span class='ltx_text ltx_font_smallcaps'>C</span> compiler |
creates an executable named <span class="ltx_text ltx_font_typewriter">a.out</span>.</p> | creates an executable named <span class='ltx_text ltx_font_typewriter'>a.out</span>.</p> |
</div> | </div> |
<div id="Ch1.S3.p3" class="ltx_para"> | <div id='Ch1.S3.p3' class='ltx_para'> |
<p class="ltx_p">In the same way the default target name <span class="ltx_text ltx_font_typewriter">a.out</span> is borrowed from | <p class='ltx_p'>In the same way the default target name <span class='ltx_text ltx_font_typewriter'>a.out</span> is borrowed from |
standard <span class="ltx_text ltx_font_smallcaps">C</span> compilers, the <span class="ltx_text ltx_font_typewriter">-o</span> option for specifying target names | standard <span class='ltx_text ltx_font_smallcaps'>C</span> compilers, the <span class='ltx_text ltx_font_typewriter'>-o</span> option for specifying target names |
is adopted as well. | is adopted as well. |
For example, <span class="ltx_text ltx_font_typewriter">sac2c -o world world.sac</span> results | For example, <span class='ltx_text ltx_font_typewriter'>sac2c -o world world.sac</span> results |
in files <span class="ltx_text ltx_font_typewriter">world.c</span> and <span class="ltx_text ltx_font_typewriter">world</span>.</p> | in files <span class='ltx_text ltx_font_typewriter'>world.c</span> and <span class='ltx_text ltx_font_typewriter'>world</span>.</p> |
</div> | </div> |
<div id="Ch1.S3.p4" class="ltx_para"> | <div id='Ch1.S3.p4' class='ltx_para'> |
<p class="ltx_p">Note here, that the compiled program, depending on the operating system, | <p class='ltx_p'>Note here, that the compiled program, depending on the operating system, |
is linked either statically or dynamically. | is linked either statically or dynamically. |
However, it does not require any further linking or interpretation.</p> | However, it does not require any further linking or interpretation.</p> |
</section> | </section> |
</section> | </section> |
<section id="Ch2" class="ltx_chapter"> | <section id='Ch2' class='ltx_chapter'> |
<h3 class="ltx_title ltx_title_chapter"> | <h3 class='ltx_title ltx_title_chapter'> |
<span class="ltx_tag ltx_tag_chapter">Chapter 2 </span>Array Programming Basics</h3> | <span class='ltx_tag ltx_tag_chapter'>Chapter 2 </span>Array Programming Basics</h3> |
| |
<div id="Ch2.p1" class="ltx_para"> | <div id='Ch2.p1' class='ltx_para'> |
<p class="ltx_p">This trail gives an introduction to the basic concepts of array programming | <p class='ltx_p'>This trail gives an introduction to the basic concepts of array programming |
in <span class="ltx_text ltx_font_smallcaps">SaC</span>. | in <span class='ltx_text ltx_font_smallcaps'>SaC</span>. |
It consists of two lessons: <span class="ltx_text ltx_font_italic">Arrays as Data</span> and <span class="ltx_text ltx_font_italic">Shape-Invariant Programming</span>. | It consists of two lessons: <span class='ltx_text ltx_font_italic'>Arrays as Data</span> and <span class='ltx_text ltx_font_italic'>Shape-Invariant Programming</span>. |
In the former lesson, the major differences between arrays in <span class="ltx_text ltx_font_smallcaps">SaC</span> and arrays | In the former lesson, the major differences between arrays in <span class='ltx_text ltx_font_smallcaps'>SaC</span> and arrays |
in more mainstream languages are explained. | in more mainstream languages are explained. |
The lesson <span class="ltx_text ltx_font_italic">Shape-Invariant Programming</span> gives an introduction into the most | The lesson <span class='ltx_text ltx_font_italic'>Shape-Invariant Programming</span> gives an introduction into the most |
important array operations available in <span class="ltx_text ltx_font_smallcaps">SaC</span>. | important array operations available in <span class='ltx_text ltx_font_smallcaps'>SaC</span>. |
Based on these operations, several small examples demonstrate how more complex | Based on these operations, several small examples demonstrate how more complex |
array operations can be constructed by simply combining the basic ones.</p> | array operations can be constructed by simply combining the basic ones.</p> |
</div> | </div> |
<section id="Ch2.S1" class="ltx_section"> | <section id='Ch2.S1' class='ltx_section'> |
<h4 class="ltx_title ltx_title_section"> | <h4 class='ltx_title ltx_title_section'> |
<span class="ltx_tag ltx_tag_section">2.1 </span>Lesson 1: Arrays as Data</h4> | <span class='ltx_tag ltx_tag_section'>2.1 </span>Lesson 1: Arrays as Data</h4> |
| |
<div id="Ch2.S1.p1" class="ltx_para"> | <div id='Ch2.S1.p1' class='ltx_para'> |
<p class="ltx_p">In <span class="ltx_text ltx_font_smallcaps">SaC</span>, arrays are the only data structures available. Even scalar values | <p class='ltx_p'>In <span class='ltx_text ltx_font_smallcaps'>SaC</span>, arrays are the only data structures available. Even scalar values |
are considered arrays. | are considered arrays. |
Each array is represented by two vectors, a so-called <em class="ltx_emph">shape vector</em> | Each array is represented by two vectors, a so-called <em class='ltx_emph'>shape vector</em> |
and a <em class="ltx_emph">data vector</em>. | and a <em class='ltx_emph'>data vector</em>. |
An array’s shape vector defines its <em class="ltx_emph">shape</em>, i.e. its extent within each axis, | An array’s shape vector defines its <em class='ltx_emph'>shape</em>, i.e. its extent within each axis, |
and its <em class="ltx_emph">dimensionality</em> (or <em class="ltx_emph">rank</em>), which is given implicitly by the shape vector’s | and its <em class='ltx_emph'>dimensionality</em> (or <em class='ltx_emph'>rank</em>), which is given implicitly by the shape vector’s |
length.</p> | length.</p> |
</div> | </div> |
<div id="Ch2.S1.p2" class="ltx_para"> | <div id='Ch2.S1.p2' class='ltx_para'> |
<p class="ltx_p">The section on <em class="ltx_emph">Defining Arrays</em> explains how arrays of various dimensionality | <p class='ltx_p'>The section on <em class='ltx_emph'>Defining Arrays</em> explains how arrays of various dimensionality |
can be defined in <span class="ltx_text ltx_font_smallcaps">SaC</span>, and how they can be generated via nesting. | can be defined in <span class='ltx_text ltx_font_smallcaps'>SaC</span>, and how they can be generated via nesting. |
Furthermore, some elementary notation such as <em class="ltx_emph">scalars</em>, <em class="ltx_emph">vectors</em>, and | Furthermore, some elementary notation such as <em class='ltx_emph'>scalars</em>, <em class='ltx_emph'>vectors</em>, and |
<em class="ltx_emph">matrices</em> is defined.</p> | <em class='ltx_emph'>matrices</em> is defined.</p> |
</div> | </div> |
<div id="Ch2.S1.p3" class="ltx_para"> | <div id='Ch2.S1.p3' class='ltx_para'> |
<p class="ltx_p">The section on <em class="ltx_emph">Arrays and Variables</em> discusses the purely functional | <p class='ltx_p'>The section on <em class='ltx_emph'>Arrays and Variables</em> discusses the purely functional |
array model used in <span class="ltx_text ltx_font_smallcaps">SaC</span>.</p> | array model used in <span class='ltx_text ltx_font_smallcaps'>SaC</span>.</p> |
</div> | </div> |
<section id="Ch2.S1.SS1" class="ltx_subsection"> | <section id='Ch2.S1.SS1' class='ltx_subsection'> |
<h5 class="ltx_title ltx_title_subsection"> | <h5 class='ltx_title ltx_title_subsection'> |
<span class="ltx_tag ltx_tag_subsection">2.1.1 </span>Defining Arrays</h5> | <span class='ltx_tag ltx_tag_subsection'>2.1.1 </span>Defining Arrays</h5> |
| |
<div id="Ch2.S1.SS1.p1" class="ltx_para"> | <div id='Ch2.S1.SS1.p1' class='ltx_para'> |
<p class="ltx_p">In this section, several means for specifying arrays are explained.</p> | <p class='ltx_p'>In this section, several means for specifying arrays are explained.</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p2" class="ltx_para"> | <div id='Ch2.S1.SS1.p2' class='ltx_para'> |
<p class="ltx_p">In principle, all arrays in <span class="ltx_text ltx_font_smallcaps">SaC</span> can be defined by using the <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span> operation. | <p class='ltx_p'>In principle, all arrays in <span class='ltx_text ltx_font_smallcaps'>SaC</span> can be defined by using the <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span> operation. |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span> expects two operands, a shape vector and a data vector, both of which | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span> expects two operands, a shape vector and a data vector, both of which |
are specified as comma separated lists of numbers enclosed in square brackets.</p> | are specified as comma separated lists of numbers enclosed in square brackets.</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p3" class="ltx_para"> | <div id='Ch2.S1.SS1.p3' class='ltx_para'> |
<p class="ltx_p">To get started, try the following program:</p> | <p class='ltx_p'>To get started, try the following program:</p> |
</div> | </div> |
<figure id="LST3" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST3' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 3: </span>Defining Arrays I</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 3: </span>Defining Arrays I</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQocmVz%0AaGFwZShbNV0sIFsxLDIsMyw0LDVdKSk7CiAgcHJpbnQocmVzaGFwZShbMywyXSwgWzEsMiwzLDQs%0ANSw2XSkpOwogIHByaW50KHJlc2hhcGUoWzMsMiwxXSwgWzEsMiwzLDQsNSw2XSkpOwogIHJldHVy%0AbiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQocmVz%0AaGFwZShbNV0sIFsxLDIsMyw0LDVdKSk7CiAgcHJpbnQocmVzaGFwZShbMywyXSwgWzEsMiwzLDQs%0ANSw2XSkpOwogIHByaW50KHJlc2hhcGUoWzMsMiwxXSwgWzEsMiwzLDQsNSw2XSkpOwogIHJldHVy%0AbiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([5],<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([5],<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([3,2],<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([3,2],<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([3,2,1],<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([3,2,1],<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S1.SS1.p4" class="ltx_para"> | <div id='Ch2.S1.SS1.p4' class='ltx_para'> |
<p class="ltx_p">It prints three arrays:</p> | <p class='ltx_p'>It prints three arrays:</p> |
<ul id="Ch2.I1" class="ltx_itemize"> | <ul id='Ch2.I1' class='ltx_itemize'> |
<li id="Ch2.I1.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I1.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I1.i1.p1" class="ltx_para"> | <div id='Ch2.I1.i1.p1' class='ltx_para'> |
<p class="ltx_p">an array of dimensionality 1 with 5 elements <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[1,2,3,4,5]</span></p> | <p class='ltx_p'>an array of dimensionality 1 with 5 elements <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[1,2,3,4,5]</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I1.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I1.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I1.i2.p1" class="ltx_para"> | <div id='Ch2.I1.i2.p1' class='ltx_para'> |
<p class="ltx_p">an array of dimensionality 2 with 3 rows and 2 columns, and</p> | <p class='ltx_p'>an array of dimensionality 2 with 3 rows and 2 columns, and</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I1.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I1.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I1.i3.p1" class="ltx_para"> | <div id='Ch2.I1.i3.p1' class='ltx_para'> |
<p class="ltx_p">a 3-dimensional array with 3 elements in the leftmost axis, | <p class='ltx_p'>a 3-dimensional array with 3 elements in the leftmost axis, |
2 elements in the middle axis, and one element in the rightmost axis.</p> | 2 elements in the middle axis, and one element in the rightmost axis.</p> |
</div> | </div> |
</ul> | </ul> |
</div> | </div> |
<div id="Ch2.S1.SS1.p5" class="ltx_para"> | <div id='Ch2.S1.SS1.p5' class='ltx_para'> |
<p class="ltx_p">Note here, that the function <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">print</span> can be applied to arbitrary arrays. | <p class='ltx_p'>Note here, that the function <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>print</span> can be applied to arbitrary arrays. |
Besides printing its argument’s dimensionality and shape, i.e. its shape vector, | Besides printing its argument’s dimensionality and shape, i.e. its shape vector, |
a more intuitive representation of the array’s data vector is shown. | a more intuitive representation of the array’s data vector is shown. |
Therefore, the 3-dimensional array is printed as a 2-dimensional array of vectors.</p> | Therefore, the 3-dimensional array is printed as a 2-dimensional array of vectors.</p> |
</div> | </div> |
<div id="Thmtheorem1" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem1' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 1. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 1. </h6> |
<div id="Thmtheorem1.p1" class="ltx_para"> | <div id='Thmtheorem1.p1' class='ltx_para'> |
<p class="ltx_p">In all these examples, the product of the shape vector matches the length of | <p class='ltx_p'>In all these examples, the product of the shape vector matches the length of |
the data vector. | the data vector. |
What do you expect to happen, if this condition does not hold?</p> | What do you expect to happen, if this condition does not hold?</p> |
</div> | </div> |
</div> | </div> |
<div id="Ch2.S1.SS1.p6" class="ltx_para ltx_noindent"> | <div id='Ch2.S1.SS1.p6' class='ltx_para ltx_noindent'> |
<p class="ltx_p">For reasons of convenience, we use the following terminology:</p> | <p class='ltx_p'>For reasons of convenience, we use the following terminology:</p> |
<dl id="Ch2.I2" class="ltx_description"> | <dl id='Ch2.I2' class='ltx_description'> |
<dt id="Ch2.I2.ix1" class="ltx_item"><span class="ltx_tag ltx_tag_description">scalar</span></dt> | <dt id='Ch2.I2.ix1' class='ltx_item'><span class='ltx_tag ltx_tag_description'>scalar</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I2.ix1.p1" class="ltx_para"> | <div id='Ch2.I2.ix1.p1' class='ltx_para'> |
<p class="ltx_p">always denotes an array of dimensionality 0,</p> | <p class='ltx_p'>always denotes an array of dimensionality 0,</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I2.ix2" class="ltx_item"><span class="ltx_tag ltx_tag_description">vector</span></dt> | <dt id='Ch2.I2.ix2' class='ltx_item'><span class='ltx_tag ltx_tag_description'>vector</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I2.ix2.p1" class="ltx_para"> | <div id='Ch2.I2.ix2.p1' class='ltx_para'> |
<p class="ltx_p">always denotes an array of dimensionality 1, and</p> | <p class='ltx_p'>always denotes an array of dimensionality 1, and</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I2.ix3" class="ltx_item"><span class="ltx_tag ltx_tag_description">matrix</span></dt> | <dt id='Ch2.I2.ix3' class='ltx_item'><span class='ltx_tag ltx_tag_description'>matrix</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I2.ix3.p1" class="ltx_para"> | <div id='Ch2.I2.ix3.p1' class='ltx_para'> |
<p class="ltx_p">always denotes an array of dimensionality 2.</p> | <p class='ltx_p'>always denotes an array of dimensionality 2.</p> |
</div> | </div> |
</dd> | </dd> |
</dl> | </dl> |
</div> | </div> |
<div id="Ch2.S1.SS1.p7" class="ltx_para"> | <div id='Ch2.S1.SS1.p7' class='ltx_para'> |
<p class="ltx_p">As <em class="ltx_emph">all</em> arrays can be defined in terms of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span>, the following | <p class='ltx_p'>As <em class='ltx_emph'>all</em> arrays can be defined in terms of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span>, the following |
program as well is perfectly legal: | program as well is perfectly legal: |
</p> | </p> |
</div> | </div> |
<figure id="LST4" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST4' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 4: </span>Defining Arrays II</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 4: </span>Defining Arrays II</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQocmVz%0AaGFwZShbMV0sIFsxXSkpOwogIHByaW50KHJlc2hhcGUoW10sIFsxXSkpOwogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQocmVz%0AaGFwZShbMV0sIFsxXSkpOwogIHByaW50KHJlc2hhcGUoW10sIFsxXSkpOwogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([1],<span class="ltx_text ltx_lst_space"> </span>[1])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([1],<span class='ltx_text ltx_lst_space'> </span>[1])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([],<span class="ltx_text ltx_lst_space"> </span>[1])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([],<span class='ltx_text ltx_lst_space'> </span>[1])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S1.SS1.p8" class="ltx_para"> | <div id='Ch2.S1.SS1.p8' class='ltx_para'> |
<p class="ltx_p">The most interesting aspect of this program is the array defined in | <p class='ltx_p'>The most interesting aspect of this program is the array defined in |
line 7. | line 7. |
The empty shape vector makes it a 0-dimensional array, i.e. a scalar. | The empty shape vector makes it a 0-dimensional array, i.e. a scalar. |
The data vector carries the scalar’s value, which, in this example, is 1.</p> | The data vector carries the scalar’s value, which, in this example, is 1.</p> |
</div> | </div> |
<div id="Thmtheorem2" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem2' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 2. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 2. </h6> |
<div id="Thmtheorem2.p1" class="ltx_para"> | <div id='Thmtheorem2.p1' class='ltx_para'> |
<p class="ltx_p">The arguments of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span> are vectors, i.e. arrays of dimensionality 1. | <p class='ltx_p'>The arguments of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span> are vectors, i.e. arrays of dimensionality 1. |
Can they be specified by <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">e</span> expressions themselves?</p> | Can they be specified by <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>e</span> expressions themselves?</p> |
</div> | </div> |
</div> | </div> |
<div id="Ch2.S1.SS1.p9" class="ltx_para"> | <div id='Ch2.S1.SS1.p9' class='ltx_para'> |
<p class="ltx_p">The <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span> notation is relatively clumsy, in particular, when | <p class='ltx_p'>The <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span> notation is relatively clumsy, in particular, when |
being used for scalars. | being used for scalars. |
Therefore, scalars and vectors can alternatively be specified by | Therefore, scalars and vectors can alternatively be specified by |
shortcut notations as well.</p> | shortcut notations as well.</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p10" class="ltx_para"> | <div id='Ch2.S1.SS1.p10' class='ltx_para'> |
<p class="ltx_p">For experimenting with these, try the following:</p> | <p class='ltx_p'>For experimenting with these, try the following:</p> |
</div> | </div> |
<figure id="LST5" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST5' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 5: </span>Shortcut Notation for Arrays</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 5: </span>Shortcut Notation for Arrays</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQoMSk7%0ACiAgcHJpbnQoWzEsMiwzLDQsNV0pOwogIHByaW50KFtbMSwyXSwgWzMsNF0sIFs1LDZdXSk7CiAg%0AcHJpbnQoZ2VuYXJyYXkoWzQsMywyXSwgMSkpOwogIHByaW50KGdlbmFycmF5KFs0LDNdLCBbMSwy%0AXSkpOwogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgcHJpbnQoMSk7%0ACiAgcHJpbnQoWzEsMiwzLDQsNV0pOwogIHByaW50KFtbMSwyXSwgWzMsNF0sIFs1LDZdXSk7CiAg%0AcHJpbnQoZ2VuYXJyYXkoWzQsMywyXSwgMSkpOwogIHByaW50KGdlbmFycmF5KFs0LDNdLCBbMSwy%0AXSkpOwogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(1); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(1); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>([1,2,3,4,5]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>([1,2,3,4,5]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>([[1,2],<span class="ltx_text ltx_lst_space"> </span>[3,4],<span class="ltx_text ltx_lst_space"> </span>[5,6]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>([[1,2],<span class='ltx_text ltx_lst_space'> </span>[3,4],<span class='ltx_text ltx_lst_space'> </span>[5,6]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">genarray</span>([4,3,2],<span class="ltx_text ltx_lst_space"> </span>1)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>genarray</span>([4,3,2],<span class='ltx_text ltx_lst_space'> </span>1)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">genarray</span>([4,3],<span class="ltx_text ltx_lst_space"> </span>[1,2])); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>genarray</span>([4,3],<span class='ltx_text ltx_lst_space'> </span>[1,2])); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S1.SS1.p11" class="ltx_para"> | <div id='Ch2.S1.SS1.p11' class='ltx_para'> |
<p class="ltx_p">From these examples, we can see that scalars can be used in the same way as in most | <p class='ltx_p'>From these examples, we can see that scalars can be used in the same way as in most |
programming languages, and that the notation used for the parameters of | programming languages, and that the notation used for the parameters of |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reshape</span> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reshape</span> |
in the examples above in fact is a standard abbreviation of <span class="ltx_text ltx_font_smallcaps">SaC</span>. | in the examples above in fact is a standard abbreviation of <span class='ltx_text ltx_font_smallcaps'>SaC</span>. |
The example in line 8 shows that nestings of arrays are implicitly eliminated, i.e. | The example in line 8 shows that nestings of arrays are implicitly eliminated, i.e. |
the resulting array is identical to:</p> | the resulting array is identical to:</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p12" class="ltx_para"> | <div id='Ch2.S1.SS1.p12' class='ltx_para'> |
<p class="ltx_p ltx_align_center"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">reshape</span>([3,2],<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6])</span>.</p> | <p class='ltx_p ltx_align_center'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,2],<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6])</span>.</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p13" class="ltx_para ltx_noindent"> | <div id='Ch2.S1.SS1.p13' class='ltx_para ltx_noindent'> |
<p class="ltx_p">For this reason, array nestings in <span class="ltx_text ltx_font_smallcaps">SaC</span> always have to be <em class="ltx_emph">homogeneous</em>, | <p class='ltx_p'>For this reason, array nestings in <span class='ltx_text ltx_font_smallcaps'>SaC</span> always have to be <em class='ltx_emph'>homogeneous</em>, |
i.e. the inner array components have to have identical shapes.</p> | i.e. the inner array components have to have identical shapes.</p> |
</div> | </div> |
<div id="Ch2.S1.SS1.p14" class="ltx_para"> | <div id='Ch2.S1.SS1.p14' class='ltx_para'> |
<p class="ltx_p">Furthermore, a new function is introduced: <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">genarray</span>. | <p class='ltx_p'>Furthermore, a new function is introduced: <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>genarray</span>. |
It expects two arguments, a shape vector that defines the shape of the result | It expects two arguments, a shape vector that defines the shape of the result |
and a default element to be inserted at each position of the result. | and a default element to be inserted at each position of the result. |
arrays as well, which implicitly extends the dimensionality of the result array.</p> | arrays as well, which implicitly extends the dimensionality of the result array.</p> |
</div> | </div> |
<div id="Thmtheorem3" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem3' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 3. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 3. </h6> |
<div id="Thmtheorem3.p1" class="ltx_para"> | <div id='Thmtheorem3.p1' class='ltx_para'> |
<p class="ltx_p">Given the language constructs introduced so far, can you define an array that would print as</p> | <p class='ltx_p'>Given the language constructs introduced so far, can you define an array that would print as</p> |
<pre class="ltx_verbatim ltx_font_typewriter"> | <pre class='ltx_verbatim ltx_font_typewriter'> |
Dimension: 3 | Dimension: 3 |
Shape : < 5, 2, 2> | Shape : < 5, 2, 2> |
< 0 0 > < 0 1 > | < 0 0 > < 0 1 > |
</pre> | </pre> |
<p class="ltx_p">but whose definition does not contain the symbol ‘1’ more than once?</p> | <p class='ltx_p'>but whose definition does not contain the symbol ‘1’ more than once?</p> |
</div> | </div> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S1.SS2" class="ltx_subsection"> | <section id='Ch2.S1.SS2' class='ltx_subsection'> |
<h5 class="ltx_title ltx_title_subsection"> | <h5 class='ltx_title ltx_title_subsection'> |
<span class="ltx_tag ltx_tag_subsection">2.1.2 </span>Arrays and Variables</h5> | <span class='ltx_tag ltx_tag_subsection'>2.1.2 </span>Arrays and Variables</h5> |
| |
<div id="Ch2.S1.SS2.p1" class="ltx_para"> | <div id='Ch2.S1.SS2.p1' class='ltx_para'> |
<p class="ltx_p">This section explains why in <span class="ltx_text ltx_font_smallcaps">SaC</span> arrays are data and not containers for values | <p class='ltx_p'>This section explains why in <span class='ltx_text ltx_font_smallcaps'>SaC</span> arrays are data and not containers for values |
as found in most other languages.</p> | as found in most other languages.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p2" class="ltx_para"> | <div id='Ch2.S1.SS2.p2' class='ltx_para'> |
<p class="ltx_p">So far, all examples were expression based, i.e. we did not use any variables. | <p class='ltx_p'>So far, all examples were expression based, i.e. we did not use any variables. |
Traditionally, there are two different ways of introducing variables. | Traditionally, there are two different ways of introducing variables. |
In conventional (imperative) languages such as <span class="ltx_text ltx_font_smallcaps">C</span>, variables denote memory | In conventional (imperative) languages such as <span class='ltx_text ltx_font_smallcaps'>C</span>, variables denote memory |
locations which hold values that may change during computation. | locations which hold values that may change during computation. |
In functional languages, similar to mathematics, variables are considered place holders for values. | In functional languages, similar to mathematics, variables are considered place holders for values. |
are involved.</p> | are involved.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p3" class="ltx_para"> | <div id='Ch2.S1.SS2.p3' class='ltx_para'> |
<p class="ltx_p">Let’s have a look at an example:</p> | <p class='ltx_p'>Let’s have a look at an example:</p> |
</div> | </div> |
<figure id="LST6" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST6' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 6: </span>Variables as Placeholders</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 6: </span>Variables as Placeholders</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKICBwcmludChhKTsKCiAgYiA9IG1vZGFycmF5KGEsIFswXSwgOSk7CiAgcHJpbnQoYik7%0ACgogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKICBwcmludChhKTsKCiAgYiA9IG1vZGFycmF5KGEsIFswXSwgOSk7CiAgcHJpbnQoYik7%0ACgogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">a</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>a</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">b</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_space"> </span>[0],<span class="ltx_text ltx_lst_space"> </span>9); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>b</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_space'> </span>[0],<span class='ltx_text ltx_lst_space'> </span>9); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">b</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>b</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S1.SS2.p4" class="ltx_para"> | <div id='Ch2.S1.SS2.p4' class='ltx_para'> |
<p class="ltx_p">The function <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">modarray</span> expects three arguments: an array to be “modified”, | <p class='ltx_p'>The function <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>modarray</span> expects three arguments: an array to be “modified”, |
an index that indicates the exact position within the array to be “modified”, | an index that indicates the exact position within the array to be “modified”, |
and the value that is to be inserted at the specified position. | and the value that is to be inserted at the specified position. |
As we would expect, the resulting array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">b</span> is almost identical to <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>, | As we would expect, the resulting array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>b</span> is almost identical to <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>, |
only the very first element has changed into <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">9</span>.</p> | only the very first element has changed into <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>9</span>.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p5" class="ltx_para"> | <div id='Ch2.S1.SS2.p5' class='ltx_para'> |
<p class="ltx_p ltx_align_center"><span class="ltx_text ltx_font_bold">Note here, that indexing in </span><span class="ltx_text ltx_font_smallcaps">SaC</span><span class="ltx_text ltx_font_bold"> always starts with index <span class="ltx_text ltx_lstlisting"></span>!</span></p> | <p class='ltx_p ltx_align_center'><span class='ltx_text ltx_font_bold'>Note here, that indexing in </span><span class='ltx_text ltx_font_smallcaps'>SaC</span><span class='ltx_text ltx_font_bold'> always starts with index <span class='ltx_text ltx_lstlisting'></span>!</span></p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p6" class="ltx_para"> | <div id='Ch2.S1.SS2.p6' class='ltx_para'> |
<p class="ltx_p">Referring to the container / place holder discussion, the crucial question is: | <p class='ltx_p'>Referring to the container / place holder discussion, the crucial question is: |
does the variable <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> denote a container, whose value is changed by | does the variable <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> denote a container, whose value is changed by |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">modarray</span>? If this would be the case, <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">b</span> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>modarray</span>? If this would be the case, <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>b</span> |
would share the same container, and every access to <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> after | would share the same container, and every access to <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> after |
line 9 would | line 9 would |
yield <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[9,2,3,4]</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> in fact is a place holder, it will | yield <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[9,2,3,4]</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> in fact is a place holder, it will |
always denote the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[1,2,3,4]</span>, no matter what functions have | always denote the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[1,2,3,4]</span>, no matter what functions have |
obtained <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> as an argument.</p> | obtained <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> as an argument.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p7" class="ltx_para"> | <div id='Ch2.S1.SS2.p7' class='ltx_para'> |
<p class="ltx_p">To answer this question, you may simply shift the first call of | <p class='ltx_p'>To answer this question, you may simply shift the first call of |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">print</span> two lines down. As you can see, in <span class="ltx_text ltx_font_smallcaps">SaC</span>, variables are indeed | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>print</span> two lines down. As you can see, in <span class='ltx_text ltx_font_smallcaps'>SaC</span>, variables are indeed |
place holders.</p> | place holders.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p8" class="ltx_para"> | <div id='Ch2.S1.SS2.p8' class='ltx_para'> |
<p class="ltx_p ltx_align_center"> | <p class='ltx_p ltx_align_center'> |
| |
<span class="ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle" style="width:390.3pt;"> | <span class='ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle' style='width:390.3pt;'> |
<span class="ltx_p"><span class="ltx_text ltx_font_bold">A note for efficiency freaks:</span></span> | <span class='ltx_p'><span class='ltx_text ltx_font_bold'>A note for efficiency freaks:</span></span> |
<span class="ltx_p"><span class="ltx_text ltx_font_italic">You may wonder whether this implies that <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">modarray</span> always copies the entire array. | <span class='ltx_p'><span class='ltx_text ltx_font_italic'>You may wonder whether this implies that <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>modarray</span> always copies the entire array. |
In fact, it only copies <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> if the place-holder property would be violated otherwise.</span></span> | In fact, it only copies <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> if the place-holder property would be violated otherwise.</span></span> |
</span> | </span> |
</p> | </p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p9" class="ltx_para"> | <div id='Ch2.S1.SS2.p9' class='ltx_para'> |
<p class="ltx_p">As a result of this place-holder property, it is guaranteed that no function call can affect | <p class='ltx_p'>As a result of this place-holder property, it is guaranteed that no function call can affect |
the value of its arguments. | the value of its arguments. |
In other words, the underlying concept <em class="ltx_emph">guarantees</em>, that all functions are | In other words, the underlying concept <em class='ltx_emph'>guarantees</em>, that all functions are |
“pure”. | “pure”. |
Although this helps in avoiding nasty errors due to non-intended side-effects, | Although this helps in avoiding nasty errors due to non-intended side-effects, |
in particular, if arrays are to be modified successively.</p> | in particular, if arrays are to be modified successively.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p10" class="ltx_para"> | <div id='Ch2.S1.SS2.p10' class='ltx_para'> |
<p class="ltx_p">To cope with this problem, in <span class="ltx_text ltx_font_smallcaps">SaC</span>, variables do have a so-called <em class="ltx_emph">scope</em>, i.e. each variable definition is associated with a well-defined portion of program code | <p class='ltx_p'>To cope with this problem, in <span class='ltx_text ltx_font_smallcaps'>SaC</span>, variables do have a so-called <em class='ltx_emph'>scope</em>, i.e. each variable definition is associated with a well-defined portion of program code |
where its definition is valid. | where its definition is valid. |
In a sequence of variable definitions, the scope of a variable starts with the left-hand | In a sequence of variable definitions, the scope of a variable starts with the left-hand |
This measure allows us to reuse variable names. | This measure allows us to reuse variable names. |
A slight modification of our example demonstrates the effect of variable scopes | A slight modification of our example demonstrates the effect of variable scopes |
in <span class="ltx_text ltx_font_smallcaps">SaC</span>:</p> | in <span class='ltx_text ltx_font_smallcaps'>SaC</span>:</p> |
</div> | </div> |
<figure id="LST7" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST7' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 7: </span>Variable Scopes</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 7: </span>Variable Scopes</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKCiAgYiA9IG1vZGFycmF5KGEsIFswXSwgOSk7CiAgcHJpbnQoYSk7CiAgYSA9IGI7CiAg%0AcHJpbnQoYSk7CgogIGEgPSBtb2RhcnJheShhLCBbMV0sIDgpOwogIHByaW50KGEpOwoKICByZXR1%0Acm4gMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKCiAgYiA9IG1vZGFycmF5KGEsIFswXSwgOSk7CiAgcHJpbnQoYSk7CiAgYSA9IGI7CiAg%0AcHJpbnQoYSk7CgogIGEgPSBtb2RhcnJheShhLCBbMV0sIDgpOwogIHByaW50KGEpOwoKICByZXR1%0Acm4gMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">b</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_space"> </span>[0],<span class="ltx_text ltx_lst_space"> </span>9); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>b</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_space'> </span>[0],<span class='ltx_text ltx_lst_space'> </span>9); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">a</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>a</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">b</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>b</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">a</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>a</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_space"> </span>[1],<span class="ltx_text ltx_lst_space"> </span>8); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_space'> </span>[1],<span class='ltx_text ltx_lst_space'> </span>8); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">a</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>a</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S1.SS2.p11" class="ltx_para"> | <div id='Ch2.S1.SS2.p11' class='ltx_para'> |
<p class="ltx_p">Here, the use of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> on the right-hand side of line 9 still refers | <p class='ltx_p'>Here, the use of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> on the right-hand side of line 9 still refers |
to the definition of line 6, whereas the use in line 11 refers to the definition | to the definition of line 6, whereas the use in line 11 refers to the definition |
in line 10.</p> | in line 10.</p> |
</div> | </div> |
<div id="Ch2.S1.SS2.p12" class="ltx_para"> | <div id='Ch2.S1.SS2.p12' class='ltx_para'> |
<p class="ltx_p">The definition in line 13 shows, how variable scopes can be used to specify | <p class='ltx_p'>The definition in line 13 shows, how variable scopes can be used to specify |
code that looks very much “imperative”. | code that looks very much “imperative”. |
However, you should always keep in mind, that in <span class="ltx_text ltx_font_smallcaps">SaC</span>, the place-holder property | However, you should always keep in mind, that in <span class='ltx_text ltx_font_smallcaps'>SaC</span>, the place-holder property |
<em class="ltx_emph">always</em> holds!</p> | <em class='ltx_emph'>always</em> holds!</p> |
</div> | </div> |
<div id="Thmtheorem4" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem4' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 4. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 4. </h6> |
<div id="Thmtheorem4.p1" class="ltx_para"> | <div id='Thmtheorem4.p1' class='ltx_para'> |
<p class="ltx_p">What result do you expect from the following <span class="ltx_text ltx_font_smallcaps">SaC</span> program?</p> | <p class='ltx_p'>What result do you expect from the following <span class='ltx_text ltx_font_smallcaps'>SaC</span> program?</p> |
</div> | </div> |
</div> | </div> |
<figure id="LST8" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST8' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 8: </span>Scope Exercise</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 8: </span>Scope Exercise</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKICBiID0gW2EsYV07CgogIGEgPSBtb2RhcnJheShtb2RhcnJheShhLCBbMF0sIDApLCBb%0AMV0sIDApOwogIGIgPSBtb2RhcnJheShiLCBbMF0sIGEpOwogIHByaW50KGIpOwoKICByZXR1cm4g%0AMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgYSA9IFsxLDIs%0AMyw0XTsKICBiID0gW2EsYV07CgogIGEgPSBtb2RhcnJheShtb2RhcnJheShhLCBbMF0sIDApLCBb%0AMV0sIDApOwogIGIgPSBtb2RhcnJheShiLCBbMF0sIGEpOwogIHByaW50KGIpOwoKICByZXR1cm4g%0AMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">b</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_identifier">a</span>]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>b</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_identifier'>a</span>]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_space"> </span>[0],<span class="ltx_text ltx_lst_space"> </span>0),<span class="ltx_text ltx_lst_space"> </span>[1],<span class="ltx_text ltx_lst_space"> </span>0); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_space'> </span>[0],<span class='ltx_text ltx_lst_space'> </span>0),<span class='ltx_text ltx_lst_space'> </span>[1],<span class='ltx_text ltx_lst_space'> </span>0); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">b</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">b</span>,<span class="ltx_text ltx_lst_space"> </span>[0],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>b</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>b</span>,<span class='ltx_text ltx_lst_space'> </span>[0],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">b</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>b</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span>} |
</div> | </div> |
</div> | </div> |
</section> | </section> |
</section> | </section> |
<section id="Ch2.S2" class="ltx_section"> | <section id='Ch2.S2' class='ltx_section'> |
<h4 class="ltx_title ltx_title_section"> | <h4 class='ltx_title ltx_title_section'> |
<span class="ltx_tag ltx_tag_section">2.2 </span>Lesson 2: Shape-Invariant Programming</h4> | <span class='ltx_tag ltx_tag_section'>2.2 </span>Lesson 2: Shape-Invariant Programming</h4> |
| |
<div id="Ch2.S2.p1" class="ltx_para"> | <div id='Ch2.S2.p1' class='ltx_para'> |
<p class="ltx_p">The term <em class="ltx_emph">shape-invariant programming</em> refers to a programming style | <p class='ltx_p'>The term <em class='ltx_emph'>shape-invariant programming</em> refers to a programming style |
where all array operations are defined in terms of operations that | where all array operations are defined in terms of operations that |
are applied to entire arrays rather than to individual array elements. | are applied to entire arrays rather than to individual array elements. |
In order to realize such a programming style, it is an essential | In order to realize such a programming style, it is an essential |
prerequisite to be able to apply functions to arbitrarily shaped arguments. | prerequisite to be able to apply functions to arbitrarily shaped arguments. |
In <span class="ltx_text ltx_font_smallcaps">SaC</span>, this is the case.</p> | In <span class='ltx_text ltx_font_smallcaps'>SaC</span>, this is the case.</p> |
</div> | </div> |
<div id="Ch2.S2.p2" class="ltx_para"> | <div id='Ch2.S2.p2' class='ltx_para'> |
<p class="ltx_p">All built-in array operations as well as all array operations supplied by the | <p class='ltx_p'>All built-in array operations as well as all array operations supplied by the |
standard library can be applied to arguments of arbitrary shapes. | standard library can be applied to arguments of arbitrary shapes. |
However, most of the operations that require more than one argument do have | However, most of the operations that require more than one argument do have |
such a kind of domain error and produce a runtime error instead.</p> | such a kind of domain error and produce a runtime error instead.</p> |
</div> | </div> |
<div id="Ch2.S2.p3" class="ltx_para"> | <div id='Ch2.S2.p3' class='ltx_para'> |
<p class="ltx_p">This lesson consists of three parts: | <p class='ltx_p'>This lesson consists of three parts: |
The section on <span class="ltx_text ltx_font_italic">Standard Array Operations</span> introduces the most important | The section on <span class='ltx_text ltx_font_italic'>Standard Array Operations</span> introduces the most important |
standard array operations provided by the current <span class="ltx_text ltx_font_smallcaps">SaC</span> compiler | standard array operations provided by the current <span class='ltx_text ltx_font_smallcaps'>SaC</span> compiler |
release<span class="ltx_note ltx_role_footnote"><sup class="ltx_note_mark">1</sup><span class="ltx_note_outer"><span class="ltx_note_content"><sup class="ltx_note_mark">1</sup>As of this writing, the latest <span class="ltx_text ltx_font_smallcaps">SaC</span> compiler release | release<span class='ltx_note ltx_role_footnote'><sup class='ltx_note_mark'>1</sup><span class='ltx_note_outer'><span class='ltx_note_content'><sup class='ltx_note_mark'>1</sup>As of this writing, the latest <span class='ltx_text ltx_font_smallcaps'>SaC</span> compiler release |
is version 1.2.</span></span></span>. | is version 1.2.</span></span></span>. |
The next section explains <span class="ltx_text ltx_font_italic">Axis Control Notation</span>, a powerful but simple | The next section explains <span class='ltx_text ltx_font_italic'>Axis Control Notation</span>, a powerful but simple |
way of manipulating the focus of array operations with respect to individual axes of argument arrays. | way of manipulating the focus of array operations with respect to individual axes of argument arrays. |
With the axis-control notation, the basic operations often can easily be combined into rather | With the axis-control notation, the basic operations often can easily be combined into rather |
complex operations as demonstrated in the section on <span class="ltx_text ltx_font_italic">Putting it all Together</span>.</p> | complex operations as demonstrated in the section on <span class='ltx_text ltx_font_italic'>Putting it all Together</span>.</p> |
</div> | </div> |
<section id="Ch2.S2.SS1" class="ltx_subsection"> | <section id='Ch2.S2.SS1' class='ltx_subsection'> |
<h5 class="ltx_title ltx_title_subsection"> | <h5 class='ltx_title ltx_title_subsection'> |
<span class="ltx_tag ltx_tag_subsection">2.2.1 </span>Standard Array Operations</h5> | <span class='ltx_tag ltx_tag_subsection'>2.2.1 </span>Standard Array Operations</h5> |
| |
<div id="Ch2.S2.SS1.p1" class="ltx_para"> | <div id='Ch2.S2.SS1.p1' class='ltx_para'> |
<p class="ltx_p">In the sequel, several toy examples demonstrate the functionality of the most basic | <p class='ltx_p'>In the sequel, several toy examples demonstrate the functionality of the most basic |
array operations that come as part of the current <span class="ltx_text ltx_font_smallcaps">SaC</span> release. | array operations that come as part of the current <span class='ltx_text ltx_font_smallcaps'>SaC</span> release. |
Their design is inspired by those available in <span class="ltx_text ltx_font_smallcaps">APL</span>. | Their design is inspired by those available in <span class='ltx_text ltx_font_smallcaps'>APL</span>. |
However, several aspects — in particular regarding the treatment of special | However, several aspects — in particular regarding the treatment of special |
cases in <span class="ltx_text ltx_font_smallcaps">APL</span> — have | cases in <span class='ltx_text ltx_font_smallcaps'>APL</span> — have |
been adjusted to allow for a more favourable compilation in <span class="ltx_text ltx_font_smallcaps">SaC</span> that yields better runtime performance.</p> | been adjusted to allow for a more favourable compilation in <span class='ltx_text ltx_font_smallcaps'>SaC</span> that yields better runtime performance.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.p2" class="ltx_para"> | <div id='Ch2.S2.SS1.p2' class='ltx_para'> |
<p class="ltx_p ltx_align_center"> | <p class='ltx_p ltx_align_center'> |
| |
<span class="ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle" style="width:390.3pt;"> | <span class='ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle' style='width:390.3pt;'> |
<span class="ltx_p"><span class="ltx_text ltx_font_bold">A note for language design freaks:</span></span> | <span class='ltx_p'><span class='ltx_text ltx_font_bold'>A note for language design freaks:</span></span> |
<span class="ltx_p"><span class="ltx_text ltx_font_italic">You may have your own ideas on what primitive array operations should be available | <span class='ltx_p'><span class='ltx_text ltx_font_italic'>You may have your own ideas on what primitive array operations should be available |
and how the precise semantics of these should look like. | and how the precise semantics of these should look like. |
Therefore, it should be mentioned here, that </span><span class="ltx_text ltx_font_bold">all</span><span class="ltx_text ltx_font_italic"> array operations introduced in the | Therefore, it should be mentioned here, that </span><span class='ltx_text ltx_font_bold'>all</span><span class='ltx_text ltx_font_italic'> array operations introduced in the |
remainder of this section are not | remainder of this section are not |
hard-wired into the language, but they are defined in the module <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">Array</span> | hard-wired into the language, but they are defined in the module <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>Array</span> |
from the standard library. | from the standard library. |
This is to say that the advanced <span class="ltx_text ltx_font_smallcaps">SaC</span> programmer may write his own set of | This is to say that the advanced <span class='ltx_text ltx_font_smallcaps'>SaC</span> programmer may write his own set of |
standard array operations. | standard array operations. |
</span></span> | </span></span> |
</p> | </p> |
</div> | </div> |
<div id="Ch2.S2.SS1.p3" class="ltx_para"> | <div id='Ch2.S2.SS1.p3' class='ltx_para'> |
<p class="ltx_p">The individual parts of this section are all organized according | <p class='ltx_p'>The individual parts of this section are all organized according |
to the following scheme: | to the following scheme: |
first, a semi-formal introduction to the functionality of individual operations | first, a semi-formal introduction to the functionality of individual operations |
with respect to domain restrictions if these do exist‘.</p> | with respect to domain restrictions if these do exist‘.</p> |
</div> | </div> |
<section id="Ch2.S2.SS1.SSSx1" class="ltx_subsubsection"> | <section id='Ch2.S2.SS1.SSSx1' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Basic Operations</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Basic Operations</h6> |
| |
<div id="Ch2.S2.SS1.SSSx1.p1" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx1.p1' class='ltx_para'> |
<p class="ltx_p">The most basic operations are very close to the model of arrays in <span class="ltx_text ltx_font_smallcaps">SaC</span>. | <p class='ltx_p'>The most basic operations are very close to the model of arrays in <span class='ltx_text ltx_font_smallcaps'>SaC</span>. |
They comprise functions for inspecting, creating, and modifying an array’s | They comprise functions for inspecting, creating, and modifying an array’s |
shape and content. | shape and content. |
already.</p> | already.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx1.p2" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx1.p2' class='ltx_para'> |
<dl id="Ch2.I3" class="ltx_description"> | <dl id='Ch2.I3' class='ltx_description'> |
<dt id="Ch2.I3.ix1" class="ltx_item"><span class="ltx_tag ltx_tag_description">dim(a)</span></dt> | <dt id='Ch2.I3.ix1' class='ltx_item'><span class='ltx_tag ltx_tag_description'>dim(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix1.p1" class="ltx_para"> | <div id='Ch2.I3.ix1.p1' class='ltx_para'> |
<p class="ltx_p">returns the (scalar) dimensionality of the argument array | <p class='ltx_p'>returns the (scalar) dimensionality of the argument array |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: none.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: none.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I3.ix2" class="ltx_item"><span class="ltx_tag ltx_tag_description">shape(a)</span></dt> | <dt id='Ch2.I3.ix2' class='ltx_item'><span class='ltx_tag ltx_tag_description'>shape(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix2.p1" class="ltx_para"> | <div id='Ch2.I3.ix2.p1' class='ltx_para'> |
<p class="ltx_p">returns the shape vector of the argument array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. | <p class='ltx_p'>returns the shape vector of the argument array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: none.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: none.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I3.ix3" class="ltx_item"><span class="ltx_tag ltx_tag_description">a[iv]</span></dt> | <dt id='Ch2.I3.ix3' class='ltx_item'><span class='ltx_tag ltx_tag_description'>a[iv]</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix3.p1" class="ltx_para"> | <div id='Ch2.I3.ix3.p1' class='ltx_para'> |
<p class="ltx_p">constitutes a short-cut notation for <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">sel</span>(<span class="ltx_text ltx_lst_identifier">iv</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>. | <p class='ltx_p'>constitutes a short-cut notation for <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>sel</span>(<span class='ltx_text ltx_lst_identifier'>iv</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>. |
It selects the array element of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> at index position <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">iv</span>. | It selects the array element of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> at index position <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>iv</span>. |
As <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> may be of any shape, the index position is given as an | As <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> may be of any shape, the index position is given as an |
<em class="ltx_emph">index vector</em>. The dimensionality of the result is identical to the dimensionality of | <em class='ltx_emph'>index vector</em>. The dimensionality of the result is identical to the dimensionality of |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> minus the length of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">iv</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> minus the length of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>iv</span>. |
Accordingly, its shape is derived from the last components of | Accordingly, its shape is derived from the last components of |
the shape of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. | the shape of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I3.I1" class="ltx_itemize"> | <ul id='Ch2.I3.I1' class='ltx_itemize'> |
<li id="Ch2.I3.I1.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I1.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I1.i1.p1" class="ltx_para"> | <div id='Ch2.I3.I1.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">iv</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>iv</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I1.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I1.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I1.i2.p1" class="ltx_para"> | <div id='Ch2.I3.I1.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">iv</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>iv</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I1.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I1.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I1.i3.p1" class="ltx_para"> | <div id='Ch2.I3.I1.i3.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I3.I1.i3.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I3.I1.i3.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>iv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>iv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math>.</p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>iv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>iv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math>.</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I3.ix4" class="ltx_item"><span class="ltx_tag ltx_tag_description">a[iv]=expr</span></dt> | <dt id='Ch2.I3.ix4' class='ltx_item'><span class='ltx_tag ltx_tag_description'>a[iv]=expr</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix4.p1" class="ltx_para"> | <div id='Ch2.I3.ix4.p1' class='ltx_para'> |
<p class="ltx_p">is a short-cut notation for an assignment of the form | <p class='ltx_p'>is a short-cut notation for an assignment of the form |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">a</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">modarray</span>(<span class="ltx_text ltx_lst_identifier">a</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">iv</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">expr</span>)</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>a</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>modarray</span>(<span class='ltx_text ltx_lst_identifier'>a</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>iv</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>expr</span>)</span>. |
The result of this application is a new array which is almost identical to | The result of this application is a new array which is almost identical to |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. Only the element (subarray) at index position <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">iv</span> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. Only the element (subarray) at index position <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>iv</span> |
is different; it is replaced by <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expr</span>. | is different; it is replaced by <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expr</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I3.I2" class="ltx_itemize"> | <ul id='Ch2.I3.I2' class='ltx_itemize'> |
<li id="Ch2.I3.I2.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I2.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I2.i1.p1" class="ltx_para"> | <div id='Ch2.I3.I2.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">iv</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>iv</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I2.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I2.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I2.i2.p1" class="ltx_para"> | <div id='Ch2.I3.I2.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">iv</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>iv</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I2.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I2.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I2.i3.p1" class="ltx_para"> | <div id='Ch2.I3.I2.i3.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I3.I2.i3.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I3.I2.i3.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>iv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>iv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>iv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>iv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I2.i4" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I2.i4' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I2.i4.p1" class="ltx_para"> | <div id='Ch2.I3.I2.i4.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">expr</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">a</span>[<span class="ltx_text ltx_lst_identifier">iv</span>])</span>.</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>expr</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>a</span>[<span class='ltx_text ltx_lst_identifier'>iv</span>])</span>.</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I3.ix5" class="ltx_item"><span class="ltx_tag ltx_tag_description">reshape(shp, expr)</span></dt> | <dt id='Ch2.I3.ix5' class='ltx_item'><span class='ltx_tag ltx_tag_description'>reshape(shp, expr)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix5.p1" class="ltx_para"> | <div id='Ch2.I3.ix5.p1' class='ltx_para'> |
<p class="ltx_p">computes an array with shape vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">shp</span> | <p class='ltx_p'>computes an array with shape vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>shp</span> |
and data vector identical to that of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expr</span>. | and data vector identical to that of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expr</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I3.I3" class="ltx_itemize"> | <ul id='Ch2.I3.I3' class='ltx_itemize'> |
<li id="Ch2.I3.I3.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I3.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I3.i1.p1" class="ltx_para"> | <div id='Ch2.I3.I3.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">shp</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>shp</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I3.I3.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I3.I3.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I3.I3.i2.p1" class="ltx_para"> | <div id='Ch2.I3.I3.i2.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I3.I3.i2.p1.m1" class="ltx_Math" alttext="{{{{{{{{\prod\limits_{i=0}^{{\textrm{\lstinline 1}}}}}\textrm{\lstinline 1}}}=\prod% | <p class='ltx_p'><math id='Ch2.I3.I3.i2.p1.m1' class='ltx_Math' alttext='{{{{{{{{\prod\limits_{i=0}^{{\textrm{\lstinline 1}}}}}\textrm{\lstinline 1}}}=\prod% |
\limits_{i=0}^{{\textrm{\lstinline 1}}}}}\textrm{\lstinline 1}}}" display="inline"><mrow><mrow><munderover><mo largeop="true" movablelimits="false" symmetric="true">∏</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>shp</mtext><mtext>)[[0]]-1</mtext></mrow></munderover><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shp</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow><mo>=</mo><mrow><munderover><mo largeop="true" movablelimits="false" symmetric="true">∏</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>dim</mtext><mtext>(</mtext><mtext>expr</mtext><mtext>)-1</mtext></mrow></munderover><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>expr</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></mrow></math>.</p> | \limits_{i=0}^{{\textrm{\lstinline 1}}}}}\textrm{\lstinline 1}}}' display='inline'><mrow><mrow><munderover><mo largeop='true' movablelimits='false' symmetric='true'>∏</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>shp</mtext><mtext>)[[0]]-1</mtext></mrow></munderover><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shp</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow><mo>=</mo><mrow><munderover><mo largeop='true' movablelimits='false' symmetric='true'>∏</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>dim</mtext><mtext>(</mtext><mtext>expr</mtext><mtext>)-1</mtext></mrow></munderover><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>expr</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></mrow></math>.</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I3.ix6" class="ltx_item"><span class="ltx_tag ltx_tag_description">genarray(shp, expr)</span></dt> | <dt id='Ch2.I3.ix6' class='ltx_item'><span class='ltx_tag ltx_tag_description'>genarray(shp, expr)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I3.ix6.p1" class="ltx_para"> | <div id='Ch2.I3.ix6.p1' class='ltx_para'> |
<p class="ltx_p">generates an array of shape <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">shp</span>, | <p class='ltx_p'>generates an array of shape <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>shp</span>, |
whose elements are all identical to <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expr</span>. | whose elements are all identical to <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expr</span>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">shp</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span>.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>shp</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span>.</p> |
</div> | </div> |
</dd> | </dd> |
</dl> | </dl> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx1.p3" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx1.p3' class='ltx_para'> |
<p class="ltx_p">Although these operations are fairly self-explaining or known from | <p class='ltx_p'>Although these operations are fairly self-explaining or known from |
Lesson <a href="#Ch2.S1" title="2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">2.1</span></a> on <span class="ltx_text ltx_font_bold">Arrays as Data</span>, let us have a look | Lesson <a href='#Ch2.S1' title='2.1 Lesson 1: Arrays as Data ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>2.1</span></a> on <span class='ltx_text ltx_font_bold'>Arrays as Data</span>, let us have a look |
at a few example applications:</p> | at a few example applications:</p> |
</div> | </div> |
<figure id="LST9" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST9' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 9: </span>Basic Operations</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 9: </span>Basic Operations</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOSwxMCwxMSwxMl07CgogIG1hdCA9IHJlc2hhcGUoWzMsNF0sIHZlY3Qp%0AOwogIHByaW50KG1hdCk7CgogIHByaW50KG1hdFtbMSwxXV0pOwogIHByaW50KG1hdFtbMl1dKTsK%0AICBwcmludChtYXRbW11dKTsKCiAgbWF0W1sxLDFdXSA9IDA7CiAgcHJpbnQobWF0KTsKICBtYXRb%0AWzJdXSA9IFswLDAsMCwwXTsKICBwcmludChtYXQpOwogIG1hdFtbXV0gPSBnZW5hcnJheShbMyw0%0AXSwgMCk7CiAgcHJpbnQobWF0KTsKCiAgZW1wdHlfdmVjdCA9IFtdOwogIHByaW50KGVtcHR5X3Zl%0AY3QpOwogIGVtcHR5X21hdCA9IHJlc2hhcGUoWzIyLDBdLCBlbXB0eV92ZWN0KTsKICBwcmludChl%0AbXB0eV9tYXQpOwogIHByaW50KGRpbShlbXB0eV9tYXQpKTsKICBwcmludChzaGFwZShlbXB0eV9t%0AYXQpKTsKCiAgcmV0dXJuIDA7Cn0=%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOSwxMCwxMSwxMl07CgogIG1hdCA9IHJlc2hhcGUoWzMsNF0sIHZlY3Qp%0AOwogIHByaW50KG1hdCk7CgogIHByaW50KG1hdFtbMSwxXV0pOwogIHByaW50KG1hdFtbMl1dKTsK%0AICBwcmludChtYXRbW11dKTsKCiAgbWF0W1sxLDFdXSA9IDA7CiAgcHJpbnQobWF0KTsKICBtYXRb%0AWzJdXSA9IFswLDAsMCwwXTsKICBwcmludChtYXQpOwogIG1hdFtbXV0gPSBnZW5hcnJheShbMyw0%0AXSwgMCk7CiAgcHJpbnQobWF0KTsKCiAgZW1wdHlfdmVjdCA9IFtdOwogIHByaW50KGVtcHR5X3Zl%0AY3QpOwogIGVtcHR5X21hdCA9IHJlc2hhcGUoWzIyLDBdLCBlbXB0eV92ZWN0KTsKICBwcmludChl%0AbXB0eV9tYXQpOwogIHByaW50KGRpbShlbXB0eV9tYXQpKTsKICBwcmludChzaGFwZShlbXB0eV9t%0AYXQpKTsKCiAgcmV0dXJuIDA7Cn0=%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6,7,8,9,10,11,12]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6,7,8,9,10,11,12]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span>([3,4],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,4],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[1,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[1,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[2]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[2]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[1,1]]<span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[1,1]]<span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[2]]<span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,0,0,0]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[2]]<span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,0,0,0]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[]]<span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">genarray</span>([3,4],<span class="ltx_text ltx_lst_space"> </span>0); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[]]<span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>genarray</span>([3,4],<span class='ltx_text ltx_lst_space'> </span>0); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">22</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">empty_vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>22</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>empty_vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">23</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">empty_vect</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>23</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>empty_vect</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">24</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">empty_mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span>([22,0],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">empty_vect</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>24</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>empty_mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span>([22,0],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>empty_vect</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">25</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">empty_mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>25</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>empty_mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">26</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">empty_mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>26</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>empty_mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">27</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">empty_mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>27</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>empty_mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">28</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>28</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">29</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>29</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">30</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>30</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS1.SSSx1.p4" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx1.p4' class='ltx_para'> |
<p class="ltx_p">The different selections in lines 11-13 show how | <p class='ltx_p'>The different selections in lines 11-13 show how |
the dimensionality of the selected element increases as the length of the index | the dimensionality of the selected element increases as the length of the index |
vector decreases. If the index vector degenerates into an empty vector, the | vector decreases. If the index vector degenerates into an empty vector, the |
of individual elements, rows, or the entire array.</p> | of individual elements, rows, or the entire array.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx1.p5" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx1.p5' class='ltx_para'> |
<p class="ltx_p">Lines 22-27 are meant to draw the reader’s | <p class='ltx_p'>Lines 22-27 are meant to draw the reader’s |
attention to the fact that there exists an unlimited number of distinct empty | attention to the fact that there exists an unlimited number of distinct empty |
arrays in <span class="ltx_text ltx_font_smallcaps">SaC</span>!</p> | arrays in <span class='ltx_text ltx_font_smallcaps'>SaC</span>!</p> |
</div> | </div> |
<div id="Thmtheorem5" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem5' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 5. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 5. </h6> |
<div id="Thmtheorem5.p1" class="ltx_para"> | <div id='Thmtheorem5.p1' class='ltx_para'> |
<p class="ltx_p">Assuming <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> to be defined as in the previous example, what results do you | <p class='ltx_p'>Assuming <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> to be defined as in the previous example, what results do you |
expect from the following expressions:</p> | expect from the following expressions:</p> |
<ul id="Ch2.I4" class="ltx_itemize"> | <ul id='Ch2.I4' class='ltx_itemize'> |
<li id="Ch2.I4.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I4.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I4.i1.p1" class="ltx_para"> | <div id='Ch2.I4.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])[[]]</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])[[]]</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I4.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I4.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I4.i2.p1" class="ltx_para"> | <div id='Ch2.I4.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])[[1]]</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])[[1]]</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I4.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I4.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I4.i3.p1" class="ltx_para"> | <div id='Ch2.I4.i3.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])[[1,0]]</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])[[1,0]]</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I4.i4" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I4.i4' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I4.i4.p1" class="ltx_para"> | <div id='Ch2.I4.i4.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">mat</span>[<span class="ltx_text ltx_lst_identifier">reshape</span>([2,0],<span class="ltx_text ltx_lst_space"> </span>[])]</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>mat</span>[<span class='ltx_text ltx_lst_identifier'>reshape</span>([2,0],<span class='ltx_text ltx_lst_space'> </span>[])]</span>?</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS1.SSSx2" class="ltx_subsubsection"> | <section id='Ch2.S2.SS1.SSSx2' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Element-wise Extensions</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Element-wise Extensions</h6> |
| |
<div id="Ch2.S2.SS1.SSSx2.p1" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx2.p1' class='ltx_para'> |
<p class="ltx_p">Most of the operations that can be found as standard operations on scalars | <p class='ltx_p'>Most of the operations that can be found as standard operations on scalars |
in other languages are applicable to entire arrays in <span class="ltx_text ltx_font_smallcaps">SaC</span>. | in other languages are applicable to entire arrays in <span class='ltx_text ltx_font_smallcaps'>SaC</span>. |
Their semantics are simply element-wise extensions of the well-known scalar | Their semantics are simply element-wise extensions of the well-known scalar |
operations. | operations. |
argument arrays.</p> | argument arrays.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx2.p2" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx2.p2' class='ltx_para'> |
<p class="ltx_p">In detail, the following operations are available:</p> | <p class='ltx_p'>In detail, the following operations are available:</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx2.p3" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx2.p3' class='ltx_para'> |
<dl id="Ch2.I5" class="ltx_description"> | <dl id='Ch2.I5' class='ltx_description'> |
<dt id="Ch2.I5.ix1" class="ltx_item"><span class="ltx_tag ltx_tag_description">arithmetic operations</span></dt> | <dt id='Ch2.I5.ix1' class='ltx_item'><span class='ltx_tag ltx_tag_description'>arithmetic operations</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I5.ix1.p1" class="ltx_para"> | <div id='Ch2.I5.ix1.p1' class='ltx_para'> |
<p class="ltx_p">including addition (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix1.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix1.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), | <p class='ltx_p'>including addition (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix1.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix1.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), |
subtraction (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix1.p1.m3" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>-<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix1.p1.m4" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), negation (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">-<math id="Ch2.I5.ix1.p1.m5" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math></span>), multiplication | subtraction (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix1.p1.m3' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>-<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix1.p1.m4' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), negation (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>-<math id='Ch2.I5.ix1.p1.m5' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math></span>), multiplication |
(<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix1.p1.m6" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>*<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix1.p1.m7" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), and division (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix1.p1.m8" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>/<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix1.p1.m9" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>). | (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix1.p1.m6' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>*<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix1.p1.m7' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), and division (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix1.p1.m8' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>/<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix1.p1.m9' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>). |
Furthermore, a modulo operation (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix1.p1.m10" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>%<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix1.p1.m11" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>) is supported on integer | Furthermore, a modulo operation (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix1.p1.m10' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>%<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix1.p1.m11' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>) is supported on integer |
numbers. | numbers. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: the element types of <math id="Ch2.I5.ix1.p1.m12" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: the element types of <math id='Ch2.I5.ix1.p1.m12' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and |
<math id="Ch2.I5.ix1.p1.m13" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same numerical type.</p> | <math id='Ch2.I5.ix1.p1.m13' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same numerical type.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I5.ix2" class="ltx_item"><span class="ltx_tag ltx_tag_description">logical operations</span></dt> | <dt id='Ch2.I5.ix2' class='ltx_item'><span class='ltx_tag ltx_tag_description'>logical operations</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I5.ix2.p1" class="ltx_para"> | <div id='Ch2.I5.ix2.p1' class='ltx_para'> |
<p class="ltx_p">including conjunction (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix2.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>&&<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix2.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), disjunction | <p class='ltx_p'>including conjunction (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix2.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>&&<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix2.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), disjunction |
(<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix2.p1.m3" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>||<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix2.p1.m4" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), and negation (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">!<math id="Ch2.I5.ix2.p1.m5" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math></span>). | (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix2.p1.m3' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>||<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix2.p1.m4' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), and negation (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>!<math id='Ch2.I5.ix2.p1.m5' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math></span>). |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: the element types have to be Boolean.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: the element types have to be Boolean.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I5.ix3" class="ltx_item"><span class="ltx_tag ltx_tag_description">relational operations</span></dt> | <dt id='Ch2.I5.ix3' class='ltx_item'><span class='ltx_tag ltx_tag_description'>relational operations</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I5.ix3.p1" class="ltx_para"> | <div id='Ch2.I5.ix3.p1' class='ltx_para'> |
<p class="ltx_p">including less-than (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span><<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), | <p class='ltx_p'>including less-than (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span><<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), |
less-or-equal (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m3" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m4" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), equal (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m5" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m6" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), | less-or-equal (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m3' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m4' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), equal (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m5' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m6' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), |
not-equal (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m7" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>!=<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m8" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), | not-equal (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m7' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>!=<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m8' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), |
greater-or-equal (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m9" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>>=<span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m10" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span>), and greater-than | greater-or-equal (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m9' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>>=<span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m10' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span>), and greater-than |
(<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><math id="Ch2.I5.ix3.p1.m11" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math><span class="ltx_text ltx_lst_space"> </span>><span class="ltx_text ltx_lst_space"> </span><math id="Ch2.I5.ix3.p1.m12" class="ltx_Math" alttext="e2" display="inline"><mrow><mi>e</mi><mo></mo><mn>2</mn></mrow></math></span>). | (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><math id='Ch2.I5.ix3.p1.m11' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math><span class='ltx_text ltx_lst_space'> </span>><span class='ltx_text ltx_lst_space'> </span><math id='Ch2.I5.ix3.p1.m12' class='ltx_Math' alttext='e2' display='inline'><mrow><mi>e</mi><mo></mo><mn>2</mn></mrow></math></span>). |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: the element types of <math id="Ch2.I5.ix3.p1.m13" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and <math id="Ch2.I5.ix3.p1.m14" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same type.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: the element types of <math id='Ch2.I5.ix3.p1.m13' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and <math id='Ch2.I5.ix3.p1.m14' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same type.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I5.ix4" class="ltx_item"><span class="ltx_tag ltx_tag_description">max (<math id="Ch2.I5.ix4.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math>, <math id="Ch2.I5.ix4.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math>), min (<math id="Ch2.I5.ix4.m3" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math>, <math id="Ch2.I5.ix4.m4" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math>)</span></dt> | <dt id='Ch2.I5.ix4' class='ltx_item'><span class='ltx_tag ltx_tag_description'>max (<math id='Ch2.I5.ix4.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math>, <math id='Ch2.I5.ix4.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math>), min (<math id='Ch2.I5.ix4.m3' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math>, <math id='Ch2.I5.ix4.m4' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math>)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I5.ix4.p1" class="ltx_para"> | <div id='Ch2.I5.ix4.p1' class='ltx_para'> |
<p class="ltx_p">compute the element-wise maximum and | <p class='ltx_p'>compute the element-wise maximum and |
minimum, respectively. | minimum, respectively. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>: the element types of <math id="Ch2.I5.ix4.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and <math id="Ch2.I5.ix4.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same type.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>: the element types of <math id='Ch2.I5.ix4.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and <math id='Ch2.I5.ix4.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> have to be of the same type.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I5.ix5" class="ltx_item"><span class="ltx_tag ltx_tag_description">where (p, <math id="Ch2.I5.ix5.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math>, <math id="Ch2.I5.ix5.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math>)</span></dt> | <dt id='Ch2.I5.ix5' class='ltx_item'><span class='ltx_tag ltx_tag_description'>where (p, <math id='Ch2.I5.ix5.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math>, <math id='Ch2.I5.ix5.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math>)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I5.ix5.p1" class="ltx_para"> | <div id='Ch2.I5.ix5.p1' class='ltx_para'> |
<p class="ltx_p">is an element-wise extension of a conditional. | <p class='ltx_p'>is an element-wise extension of a conditional. |
It expects <math id="Ch2.I5.ix5.p1.m1" class="ltx_Math" alttext="p" display="inline"><mi>p</mi></math>, <math id="Ch2.I5.ix5.p1.m2" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math>, and <math id="Ch2.I5.ix5.p1.m3" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> either to have identical shapes | It expects <math id='Ch2.I5.ix5.p1.m1' class='ltx_Math' alttext='p' display='inline'><mi>p</mi></math>, <math id='Ch2.I5.ix5.p1.m2' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math>, and <math id='Ch2.I5.ix5.p1.m3' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> either to have identical shapes |
or to be scalar. If at least one of the three arrays is non-scalar, that | or to be scalar. If at least one of the three arrays is non-scalar, that |
shape serves as shape of the result, whose values are taken from | shape serves as shape of the result, whose values are taken from |
<math id="Ch2.I5.ix5.p1.m4" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> or <math id="Ch2.I5.ix5.p1.m5" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> depending on the value (s) of <math id="Ch2.I5.ix5.p1.m6" class="ltx_Math" alttext="p" display="inline"><mi>p</mi></math>. | <math id='Ch2.I5.ix5.p1.m4' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> or <math id='Ch2.I5.ix5.p1.m5' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> depending on the value (s) of <math id='Ch2.I5.ix5.p1.m6' class='ltx_Math' alttext='p' display='inline'><mi>p</mi></math>. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I5.I1" class="ltx_itemize"> | <ul id='Ch2.I5.I1' class='ltx_itemize'> |
<li id="Ch2.I5.I1.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I5.I1.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I5.I1.i1.p1" class="ltx_para"> | <div id='Ch2.I5.I1.i1.p1' class='ltx_para'> |
<p class="ltx_p">the element type of <math id="Ch2.I5.I1.i1.p1.m1" class="ltx_Math" alttext="p" display="inline"><mi>p</mi></math> has to be boolean | <p class='ltx_p'>the element type of <math id='Ch2.I5.I1.i1.p1.m1' class='ltx_Math' alttext='p' display='inline'><mi>p</mi></math> has to be boolean |
</p> | </p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I5.I1.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I5.I1.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I5.I1.i2.p1" class="ltx_para"> | <div id='Ch2.I5.I1.i2.p1' class='ltx_para'> |
<p class="ltx_p">the element types of <math id="Ch2.I5.I1.i2.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and <math id="Ch2.I5.I1.i2.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> have to be identical</p> | <p class='ltx_p'>the element types of <math id='Ch2.I5.I1.i2.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and <math id='Ch2.I5.I1.i2.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> have to be identical</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I5.I1.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I5.I1.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I5.I1.i3.p1" class="ltx_para"> | <div id='Ch2.I5.I1.i3.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I5.I1.i3.p1.m1" class="ltx_Math" alttext="{{{{{{{{{{{{{{\exists\textrm{\lstinline 1}}}:((\textrm{\lstinline 1}}}\vee\textrm{\lstinline | <p class='ltx_p'><math id='Ch2.I5.I1.i3.p1.m1' class='ltx_Math' alttext='{{{{{{{{{{{{{{\exists\textrm{\lstinline 1}}}:((\textrm{\lstinline 1}}}\vee\textrm{\lstinline |
1% | 1% |
}}})\wedge(\textrm{\lstinline 1}}}\vee\textrm{\lstinline 1}}})\wedge(\textrm{% | }}})\wedge(\textrm{\lstinline 1}}}\vee\textrm{\lstinline 1}}})\wedge(\textrm{% |
\lstinline 1}}}\vee\textrm{\lstinline 1}}}))" display="inline"><mrow><mrow><mo>∃</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">shp</mtext></mrow><mo>:</mo><mrow><mo stretchy="false">(</mo><mrow><mrow><mo stretchy="false">(</mo><mrow><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>p</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>p</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy="false">)</mo></mrow><mo>∧</mo><mrow><mo stretchy="false">(</mo><mrow><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>e_1</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>e_1</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy="false">)</mo></mrow><mo>∧</mo><mrow><mo stretchy="false">(</mo><mrow><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>e_2</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>e_2</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy="false">)</mo></mrow></mrow><mo stretchy="false">)</mo></mrow></mrow></math>.</p> | \lstinline 1}}}\vee\textrm{\lstinline 1}}}))' display='inline'><mrow><mrow><mo>∃</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>shp</mtext></mrow><mo>:</mo><mrow><mo stretchy='false'>(</mo><mrow><mrow><mo stretchy='false'>(</mo><mrow><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>p</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>p</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy='false'>)</mo></mrow><mo>∧</mo><mrow><mo stretchy='false'>(</mo><mrow><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>e_1</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>e_1</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy='false'>)</mo></mrow><mo>∧</mo><mrow><mo stretchy='false'>(</mo><mrow><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>e_2</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>shp</mtext></mrow><mo>∨</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>e_2</mtext><mtext>)</mtext><mtext> </mtext><mtext>==</mtext><mtext> </mtext><mtext>[]</mtext></mrow></mrow><mo stretchy='false'>)</mo></mrow></mrow><mo stretchy='false'>)</mo></mrow></mrow></math>.</p> |
</div> | </div> |
</li> | </li> |
</dl> | </dl> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx2.p4" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx2.p4' class='ltx_para'> |
<p class="ltx_p">Again, these operations are fairly self-explanatory. | <p class='ltx_p'>Again, these operations are fairly self-explanatory. |
Nevertheless, we present a few examples:</p> | Nevertheless, we present a few examples:</p> |
</div> | </div> |
<figure id="LST10" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST10' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 10: </span>Elementwise Extensions</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 10: </span>Elementwise Extensions</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBtYXQyID0gd2hlcmUobWF0ICUgMiA9PSAwLCBtYXQsIC1tYXQpOwogIHBy%0AaW50KG1hdDIpOwoKICBwcmludChtYXgobWF0MiwgMCkpOwoKICByZXR1cm4gMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBtYXQyID0gd2hlcmUobWF0ICUgMiA9PSAwLCBtYXQsIC1tYXQpOwogIHBy%0AaW50KG1hdDIpOwoKICBwcmludChtYXgobWF0MiwgMCkpOwoKICByZXR1cm4gMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">vect</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+10,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+20]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>vect</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+10,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+20]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat2</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">where</span>(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>%<span class="ltx_text ltx_lst_space"> </span>2<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>0,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>,<span class="ltx_text ltx_lst_space"> </span>-<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat2</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>where</span>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>%<span class='ltx_text ltx_lst_space'> </span>2<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>0,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>,<span class='ltx_text ltx_lst_space'> </span>-<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat2</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat2</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">max</span>(<span class="ltx_text ltx_lst_identifier">mat2</span>,<span class="ltx_text ltx_lst_space"> </span>0)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>max</span>(<span class='ltx_text ltx_lst_identifier'>mat2</span>,<span class='ltx_text ltx_lst_space'> </span>0)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS1.SSSx2.p5" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx2.p5' class='ltx_para'> |
<p class="ltx_p">The most interesting part of this example is the definition | <p class='ltx_p'>The most interesting part of this example is the definition |
of the matrix <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat2</span> in line 11. | of the matrix <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat2</span> in line 11. |
The even numbers from the matrix <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> are taken as they are, whereas | The even numbers from the matrix <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> are taken as they are, whereas |
the odd numbers are negated. | the odd numbers are negated. |
Note here, that all sub expressions in predicate position are in fact non-scalar | Note here, that all sub expressions in predicate position are in fact non-scalar |
arrays: <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>\%<span class="ltx_text ltx_lst_space"> </span>2)</span> denotes a matrix of zeros and ones and | arrays: <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>\%<span class='ltx_text ltx_lst_space'> </span>2)</span> denotes a matrix of zeros and ones and |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>\%<span class="ltx_text ltx_lst_space"> </span>2)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span></span> denotes a matrix of boolean values.</p> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>\%<span class='ltx_text ltx_lst_space'> </span>2)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span></span> denotes a matrix of boolean values.</p> |
</div> | </div> |
<div id="Thmtheorem6" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem6' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 6. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 6. </h6> |
<div id="Thmtheorem6.p1" class="ltx_para"> | <div id='Thmtheorem6.p1' class='ltx_para'> |
<p class="ltx_p">What results do you expect from the following expressions:</p> | <p class='ltx_p'>What results do you expect from the following expressions:</p> |
<ul id="Ch2.I6" class="ltx_itemize"> | <ul id='Ch2.I6' class='ltx_itemize'> |
<li id="Ch2.I6.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I6.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I6.i1.p1" class="ltx_para"> | <div id='Ch2.I6.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">min</span>(<span class="ltx_text ltx_lst_identifier">reshape</span>([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[]),<span class="ltx_text ltx_lst_space"> </span>42)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>min</span>(<span class='ltx_text ltx_lst_identifier'>reshape</span>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[]),<span class='ltx_text ltx_lst_space'> </span>42)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I6.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I6.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I6.i2.p1" class="ltx_para"> | <div id='Ch2.I6.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">reshape</span>([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span>([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I6.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I6.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I6.i3.p1" class="ltx_para"> | <div id='Ch2.I6.i3.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">reshape</span>([1,1],<span class="ltx_text ltx_lst_space"> </span>[1])<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span>([1],<span class="ltx_text ltx_lst_space"> </span>[1])</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>reshape</span>([1,1],<span class='ltx_text ltx_lst_space'> </span>[1])<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span>([1],<span class='ltx_text ltx_lst_space'> </span>[1])</span>?</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS1.SSSx3" class="ltx_subsubsection"> | <section id='Ch2.S2.SS1.SSSx3' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Restructuring Operations</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Restructuring Operations</h6> |
| |
<div id="Ch2.S2.SS1.SSSx3.p1" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p1' class='ltx_para'> |
<p class="ltx_p">The operations to be introduced here do not compute new values at all. | <p class='ltx_p'>The operations to be introduced here do not compute new values at all. |
Instead, they are meant to create slightly differently structured arrays | Instead, they are meant to create slightly differently structured arrays |
from existing ones. | from existing ones. |
Therefore, they are applicable to arrays of all built-in element types.</p> | Therefore, they are applicable to arrays of all built-in element types.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx3.p2" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p2' class='ltx_para'> |
<dl id="Ch2.I7" class="ltx_description"> | <dl id='Ch2.I7' class='ltx_description'> |
<dt id="Ch2.I7.ix1" class="ltx_item"><span class="ltx_tag ltx_tag_description">take(sv, a)</span></dt> | <dt id='Ch2.I7.ix1' class='ltx_item'><span class='ltx_tag ltx_tag_description'>take(sv, a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix1.p1" class="ltx_para"> | <div id='Ch2.I7.ix1.p1' class='ltx_para'> |
<p class="ltx_p">takes as many elements from the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> as indicated | <p class='ltx_p'>takes as many elements from the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> as indicated |
by the shape vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span>. Each element of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> corresponds to | by the shape vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span>. Each element of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> corresponds to |
one axis of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> starting from the leftmost one. | one axis of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> starting from the leftmost one. |
For positive components of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span>, the elements are taken from the | For positive components of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span>, the elements are taken from the |
“beginning”, i.e. starting with index 0, otherwise they are taken | “beginning”, i.e. starting with index 0, otherwise they are taken |
from the “end” including the maximum legal index of the corresponding | from the “end” including the maximum legal index of the corresponding |
axis. | axis. |
All axes of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> where there exists no corresponding element in | All axes of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> where there exists no corresponding element in |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> are taken entirely. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> are taken entirely. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I1" class="ltx_itemize"> | <ul id='Ch2.I7.I1' class='ltx_itemize'> |
<li id="Ch2.I7.I1.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I1.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I1.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I1.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I1.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I1.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I1.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I1.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I1.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I1.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I1.i3.p1" class="ltx_para"> | <div id='Ch2.I7.I1.i3.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I1.i3.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I7.I1.i3.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I7.ix2" class="ltx_item"><span class="ltx_tag ltx_tag_description">drop(sv, a)</span></dt> | <dt id='Ch2.I7.ix2' class='ltx_item'><span class='ltx_tag ltx_tag_description'>drop(sv, a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix2.p1" class="ltx_para"> | <div id='Ch2.I7.ix2.p1' class='ltx_para'> |
<p class="ltx_p">drops as many elements from the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> as indicated | <p class='ltx_p'>drops as many elements from the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> as indicated |
by the shape vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span>. Each element of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> corresponds to | by the shape vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span>. Each element of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> corresponds to |
one axis of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> starting from the leftmost one. | one axis of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> starting from the leftmost one. |
For positive components of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span>, the elements are dropped from the | For positive components of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span>, the elements are dropped from the |
“beginning”, i.e. starting with index 0, otherwise they are dropped | “beginning”, i.e. starting with index 0, otherwise they are dropped |
from the “end” starting from the maximum legal index of the corresponding | from the “end” starting from the maximum legal index of the corresponding |
axis. | axis. |
All axes of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> where there exists no corresponding element in | All axes of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> where there exists no corresponding element in |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> are left untouched. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> are left untouched. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I2" class="ltx_itemize"> | <ul id='Ch2.I7.I2' class='ltx_itemize'> |
<li id="Ch2.I7.I2.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I2.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I2.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I2.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)=<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)=<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I2.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I2.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I2.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I2.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I2.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I2.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I2.i3.p1" class="ltx_para"> | <div id='Ch2.I7.I2.i3.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I2.i3.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I7.I2.i3.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I7.ix3" class="ltx_item"><span class="ltx_tag ltx_tag_description">tile(sv, ov, a)</span></dt> | <dt id='Ch2.I7.ix3' class='ltx_item'><span class='ltx_tag ltx_tag_description'>tile(sv, ov, a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix3.p1" class="ltx_para"> | <div id='Ch2.I7.ix3.p1' class='ltx_para'> |
<p class="ltx_p">takes a tile of shape <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> from <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> | <p class='ltx_p'>takes a tile of shape <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> from <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> |
starting at the index specified by the offset vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span>. | starting at the index specified by the offset vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span>. |
For axes where no values of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sv</span> or <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span> are specified | For axes where no values of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sv</span> or <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span> are specified |
these are assumed to be identical to the extent of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> along that axis or 0, | these are assumed to be identical to the extent of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> along that axis or 0, |
respectively. | respectively. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I3" class="ltx_itemize"> | <ul id='Ch2.I7.I3' class='ltx_itemize'> |
<li id="Ch2.I7.I3.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span> |
</p> | </p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I3.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">sv</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>sv</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I3.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i3.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i3.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I3.i4" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i4' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i4.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i4.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I3.i4.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I7.I3.i4.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>ov</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>ov</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I3.i5" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i5' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i5.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i5.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I3.i5.p1.m1" class="ltx_Math" alttext="{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% | <p class='ltx_p'><math id='Ch2.I7.I3.i5.p1.m1' class='ltx_Math' alttext='{{{{{{\forall\textrm{\lstinline 1}}}\in\{0,\dots,\textrm{\lstinline 1}}}\}:\textrm{% |
\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mn>0</mn><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>min</mtext><mtext>(</mtext><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]],</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]])</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>ov</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext>+</mtext><mtext> </mtext><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mn>0</mn><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>min</mtext><mtext>(</mtext><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]],</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]])</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>ov</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext>+</mtext><mtext> </mtext><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I3.i6" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I3.i6' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I3.i6.p1" class="ltx_para"> | <div id='Ch2.I7.I3.i6.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I3.i6.p1.m1" class="ltx_Math" alttext="{{{{{{{{\forall\textrm{\lstinline 1}}}\in\{\textrm{\lstinline 1}}},\dots,\textrm{% | <p class='ltx_p'><math id='Ch2.I7.I3.i6.p1.m1' class='ltx_Math' alttext='{{{{{{{{\forall\textrm{\lstinline 1}}}\in\{\textrm{\lstinline 1}}},\dots,\textrm{% |
\lstinline 1}}}\}:\textrm{\lstinline 1}}}" display="inline"><mrow><mrow><mrow><mo>∀</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</mtext></mrow><mo>∈</mo><mrow><mo stretchy="false">{</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>min</mtext><mtext>(</mtext><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]],</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]])</mtext></mrow><mo>,</mo><mi mathvariant="normal">…</mi><mo>,</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy="false">}</mo></mrow></mrow><mo>:</mo><mrow class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> | \lstinline 1}}}\}:\textrm{\lstinline 1}}}' display='inline'><mrow><mrow><mrow><mo>∀</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</mtext></mrow><mo>∈</mo><mrow><mo stretchy='false'>{</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>min</mtext><mtext>(</mtext><mtext>shape</mtext><mtext>(</mtext><mtext>ov</mtext><mtext>)[[0]],</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]])</mtext></mrow><mo>,</mo><mi mathvariant='normal'>…</mi><mo>,</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>shape</mtext><mtext>(</mtext><mtext>sv</mtext><mtext>)[[0]]</mtext></mrow><mo stretchy='false'>}</mo></mrow></mrow><mo>:</mo><mrow class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><mtext>sv</mtext><mtext>[[</mtext><mtext>i</mtext><mtext>]]</mtext><mtext> </mtext><mtext><=</mtext><mtext> </mtext><mtext>shape</mtext><mtext>(</mtext><mtext>a</mtext><mtext>)[[</mtext><mtext>i</mtext><mtext>]]</mtext></mrow></mrow></math></p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I7.ix4" class="ltx_item"><span class="ltx_tag ltx_tag_description"><math id="Ch2.I7.ix4.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> ++ <math id="Ch2.I7.ix4.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math></span></dt> | <dt id='Ch2.I7.ix4' class='ltx_item'><span class='ltx_tag ltx_tag_description'><math id='Ch2.I7.ix4.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> ++ <math id='Ch2.I7.ix4.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math></span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix4.p1" class="ltx_para"> | <div id='Ch2.I7.ix4.p1' class='ltx_para'> |
<p class="ltx_p">concatenates arrays <math id="Ch2.I7.ix4.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and <math id="Ch2.I7.ix4.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> with respect to the leftmost axis. | <p class='ltx_p'>concatenates arrays <math id='Ch2.I7.ix4.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and <math id='Ch2.I7.ix4.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> with respect to the leftmost axis. |
As in <span class="ltx_text ltx_font_smallcaps">SaC</span> all arrays are homogeneous, this requires all but the leftmost | As in <span class='ltx_text ltx_font_smallcaps'>SaC</span> all arrays are homogeneous, this requires all but the leftmost |
axis to be of identical extent. | axis to be of identical extent. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I4" class="ltx_itemize"> | <ul id='Ch2.I7.I4' class='ltx_itemize'> |
<li id="Ch2.I7.I4.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I4.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I4.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I4.i1.p1' class='ltx_para'> |
<p class="ltx_p"><math id="Ch2.I7.I4.i1.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math> and <math id="Ch2.I7.I4.i1.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math> have to be of identical element type</p> | <p class='ltx_p'><math id='Ch2.I7.I4.i1.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math> and <math id='Ch2.I7.I4.i1.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math> have to be of identical element type</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I4.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I4.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I4.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I4.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">drop</span>(1,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">shape</span>(<math id="Ch2.I7.I4.i2.p1.m1" class="ltx_Math" alttext="e_{1}" display="inline"><msub><mi>e</mi><mn>1</mn></msub></math>))<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">drop</span>(1,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">shape</span>(<math id="Ch2.I7.I4.i2.p1.m2" class="ltx_Math" alttext="e_{2}" display="inline"><msub><mi>e</mi><mn>2</mn></msub></math>))</span>.</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>drop</span>(1,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>shape</span>(<math id='Ch2.I7.I4.i2.p1.m1' class='ltx_Math' alttext='e_{1}' display='inline'><msub><mi>e</mi><mn>1</mn></msub></math>))<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>drop</span>(1,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>shape</span>(<math id='Ch2.I7.I4.i2.p1.m2' class='ltx_Math' alttext='e_{2}' display='inline'><msub><mi>e</mi><mn>2</mn></msub></math>))</span>.</p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I7.ix5" class="ltx_item"><span class="ltx_tag ltx_tag_description">rotate(ov, a)</span></dt> | <dt id='Ch2.I7.ix5' class='ltx_item'><span class='ltx_tag ltx_tag_description'>rotate(ov, a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix5.p1" class="ltx_para"> | <div id='Ch2.I7.ix5.p1' class='ltx_para'> |
<p class="ltx_p">rotates the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> with respect to those axes specified | <p class='ltx_p'>rotates the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> with respect to those axes specified |
by the offset vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span>. | by the offset vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span>. |
Starting from the leftmost axis, the elements of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span> specify by how many | Starting from the leftmost axis, the elements of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span> specify by how many |
positions the elements are rotated towards increasing indices (positive values) | positions the elements are rotated towards increasing indices (positive values) |
or towards decreasing indices (negative values). | or towards decreasing indices (negative values). |
<span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I5" class="ltx_itemize"> | <ul id='Ch2.I7.I5' class='ltx_itemize'> |
<li id="Ch2.I7.I5.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I5.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I5.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I5.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I5.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I5.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I5.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I5.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I7.ix6" class="ltx_item"><span class="ltx_tag ltx_tag_description">shift(ov, expr, a)</span></dt> | <dt id='Ch2.I7.ix6' class='ltx_item'><span class='ltx_tag ltx_tag_description'>shift(ov, expr, a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I7.ix6.p1" class="ltx_para"> | <div id='Ch2.I7.ix6.p1' class='ltx_para'> |
<p class="ltx_p">shifts the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> with respect to those axes specified | <p class='ltx_p'>shifts the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> with respect to those axes specified |
by the offset vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span>. | by the offset vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span>. |
The element positions that become “void” are filled by the (scalar) | The element positions that become “void” are filled by the (scalar) |
default element <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expr</span>. | default element <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expr</span>. |
Again, depending on the sign of the values of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">ov</span> the elements | Again, depending on the sign of the values of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>ov</span> the elements |
are either shifted towards increasing or decreasing indices. | are either shifted towards increasing or decreasing indices. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions</span>:</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions</span>:</p> |
<ul id="Ch2.I7.I6" class="ltx_itemize"> | <ul id='Ch2.I7.I6' class='ltx_itemize'> |
<li id="Ch2.I7.I6.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I6.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I6.i1.p1" class="ltx_para"> | <div id='Ch2.I7.I6.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>1</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>1</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I6.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I6.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I6.i2.p1" class="ltx_para"> | <div id='Ch2.I7.I6.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">ov</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span><=<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">dim</span>(<span class="ltx_text ltx_lst_identifier">a</span>)</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>ov</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span><=<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>dim</span>(<span class='ltx_text ltx_lst_identifier'>a</span>)</span></p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I7.I6.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I7.I6.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize"><span class="ltx_text ltx_font_bold">–</span></span> | <span class='ltx_tag ltx_tag_itemize'><span class='ltx_text ltx_font_bold'>–</span></span> |
<div id="Ch2.I7.I6.i3.p1" class="ltx_para"> | <div id='Ch2.I7.I6.i3.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shape</span>(<span class="ltx_text ltx_lst_identifier">expr</span>)[[0]]<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>[]</span></p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shape</span>(<span class='ltx_text ltx_lst_identifier'>expr</span>)[[0]]<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>[]</span></p> |
</div> | </div> |
</li> | </li> |
</dl> | </dl> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx3.p3" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p3' class='ltx_para'> |
<p class="ltx_p">A few examples:</p> | <p class='ltx_p'>A few examples:</p> |
</div> | </div> |
<figure id="LST11" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST11' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 11: </span>Restructuring Operations</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 11: </span>Restructuring Operations</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBwcmludCh0YWtlKFsyLC0yXSwgbWF0KSk7CiAgcHJpbnQodGFrZShbMl0s%0AIG1hdCkpOwogIHByaW50KHRha2UoW10sIG1hdCkpOwoKICBwcmludCh0YWtlKFswXSwgbWF0KSk7%0ACiAgcHJpbnQodGFrZShbMiwgMF0sIG1hdCkpOwogIHByaW50KHRha2UoWzJdLCByZXNoYXBlKFsz%0ALDAsNV0sIFtdKSkpOwoKICBwcmludChkcm9wKFswLCAtMV0sIG1hdCkpOwoKICBwcmludChtYXQg%0AKysgbWF0KTsKCiAgcHJpbnQocm90YXRlKFstMSwgNDJdLCBtYXQpKTsKICBwcmludChyb3RhdGUo%0AWyAxXSwgbWF0KSk7CgogIHByaW50KHNoaWZ0KFswLCAtMl0sIDAsIG1hdCkpOwogIHByaW50KHNo%0AaWZ0KFswLCAtMjJdLCAwLCBtYXQpKTsKICBwcmludChzaGlmdChbMV0sIDAsIG1hdCkpOwoKICBy%0AZXR1cm4gMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBwcmludCh0YWtlKFsyLC0yXSwgbWF0KSk7CiAgcHJpbnQodGFrZShbMl0s%0AIG1hdCkpOwogIHByaW50KHRha2UoW10sIG1hdCkpOwoKICBwcmludCh0YWtlKFswXSwgbWF0KSk7%0ACiAgcHJpbnQodGFrZShbMiwgMF0sIG1hdCkpOwogIHByaW50KHRha2UoWzJdLCByZXNoYXBlKFsz%0ALDAsNV0sIFtdKSkpOwoKICBwcmludChkcm9wKFswLCAtMV0sIG1hdCkpOwoKICBwcmludChtYXQg%0AKysgbWF0KTsKCiAgcHJpbnQocm90YXRlKFstMSwgNDJdLCBtYXQpKTsKICBwcmludChyb3RhdGUo%0AWyAxXSwgbWF0KSk7CgogIHByaW50KHNoaWZ0KFswLCAtMl0sIDAsIG1hdCkpOwogIHByaW50KHNo%0AaWZ0KFswLCAtMjJdLCAwLCBtYXQpKTsKICBwcmludChzaGlmdChbMV0sIDAsIG1hdCkpOwoKICBy%0AZXR1cm4gMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">vect</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+10,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+20]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>vect</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+10,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+20]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([2,-2],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([2,-2],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([2],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([2],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([0],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([0],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([2,<span class="ltx_text ltx_lst_space"> </span>0],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([2,<span class='ltx_text ltx_lst_space'> </span>0],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">take</span>([2],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span>([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[]))); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>take</span>([2],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[]))); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">drop</span>([0,<span class="ltx_text ltx_lst_space"> </span>-1],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>drop</span>([0,<span class='ltx_text ltx_lst_space'> </span>-1],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>++<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>++<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">22</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>22</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">23</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">rotate</span>([-1,<span class="ltx_text ltx_lst_space"> </span>42],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>23</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>rotate</span>([-1,<span class='ltx_text ltx_lst_space'> </span>42],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">24</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">rotate</span>([<span class="ltx_text ltx_lst_space"> </span>1],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>24</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>rotate</span>([<span class='ltx_text ltx_lst_space'> </span>1],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">25</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>25</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">26</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">shift</span>([0,<span class="ltx_text ltx_lst_space"> </span>-2],<span class="ltx_text ltx_lst_space"> </span>0,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>26</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>shift</span>([0,<span class='ltx_text ltx_lst_space'> </span>-2],<span class='ltx_text ltx_lst_space'> </span>0,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">27</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">shift</span>([0,<span class="ltx_text ltx_lst_space"> </span>-22],<span class="ltx_text ltx_lst_space"> </span>0,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>27</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>shift</span>([0,<span class='ltx_text ltx_lst_space'> </span>-22],<span class='ltx_text ltx_lst_space'> </span>0,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">28</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">shift</span>([1],<span class="ltx_text ltx_lst_space"> </span>0,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>28</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>shift</span>([1],<span class='ltx_text ltx_lst_space'> </span>0,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">29</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>29</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">30</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>30</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">31</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>31</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS1.SSSx3.p4" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p4' class='ltx_para'> |
<p class="ltx_p">The applications of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">take</span> in lines 11-13 demonstrate, how the | <p class='ltx_p'>The applications of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>take</span> in lines 11-13 demonstrate, how the |
dimensionality of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> remains unaffected by the length of the | dimensionality of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> remains unaffected by the length of the |
first argument. | first argument. |
Only the shape of the result and the “side” from which the elements | Only the shape of the result and the “side” from which the elements |
are taken is defined by it.</p> | are taken is defined by it.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx3.p5" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p5' class='ltx_para'> |
<p class="ltx_p">The applications in lines 15-17 demonstrate how empty arrays are dealt | <p class='ltx_p'>The applications in lines 15-17 demonstrate how empty arrays are dealt |
with in the individual argument positions. | with in the individual argument positions. |
In particular from the example in line 17 it can be seen how well the | In particular from the example in line 17 it can be seen how well the |
fits nicely into the overall framework.</p> | fits nicely into the overall framework.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx3.p6" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx3.p6' class='ltx_para'> |
<p class="ltx_p">The remaining examples are rather straightforward. | <p class='ltx_p'>The remaining examples are rather straightforward. |
The only aspect of interest here may be the “overflows” in the | The only aspect of interest here may be the “overflows” in the |
rotation and shift parameters in lines 24 and 28, respectively.</p> | rotation and shift parameters in lines 24 and 28, respectively.</p> |
</div> | </div> |
<div id="Thmtheorem7" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem7' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 7. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 7. </h6> |
<div id="Thmtheorem7.p1" class="ltx_para"> | <div id='Thmtheorem7.p1' class='ltx_para'> |
<p class="ltx_p">Which of the following expressions can be reformulated in terms | <p class='ltx_p'>Which of the following expressions can be reformulated in terms |
of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">take</span>, <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">++</span>, and the basic operations defined | of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>take</span>, <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>++</span>, and the basic operations defined |
in the previous parts?</p> | in the previous parts?</p> |
<ul id="Ch2.I8" class="ltx_itemize"> | <ul id='Ch2.I8' class='ltx_itemize'> |
<li id="Ch2.I8.i1" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i1' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i1.p1" class="ltx_para"> | <div id='Ch2.I8.i1.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">drop</span><span class="ltx_text ltx_lst_space"> </span>(<span class="ltx_text ltx_lst_identifier">v</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>drop</span><span class='ltx_text ltx_lst_space'> </span>(<span class='ltx_text ltx_lst_identifier'>v</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I8.i2" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i2' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i2.p1" class="ltx_para"> | <div id='Ch2.I8.i2.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">tile</span><span class="ltx_text ltx_lst_space"> </span>(<span class="ltx_text ltx_lst_identifier">v</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">o</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>tile</span><span class='ltx_text ltx_lst_space'> </span>(<span class='ltx_text ltx_lst_identifier'>v</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>o</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I8.i3" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i3' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i3.p1" class="ltx_para"> | <div id='Ch2.I8.i3.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shift</span><span class="ltx_text ltx_lst_space"> </span>([<span class="ltx_text ltx_lst_identifier">n</span>],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">e</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shift</span><span class='ltx_text ltx_lst_space'> </span>([<span class='ltx_text ltx_lst_identifier'>n</span>],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>e</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I8.i4" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i4' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i4.p1" class="ltx_para"> | <div id='Ch2.I8.i4.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">shift</span><span class="ltx_text ltx_lst_space"> </span>([<span class="ltx_text ltx_lst_identifier">m</span>,<span class="ltx_text ltx_lst_identifier">n</span>],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">e</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>shift</span><span class='ltx_text ltx_lst_space'> </span>([<span class='ltx_text ltx_lst_identifier'>m</span>,<span class='ltx_text ltx_lst_identifier'>n</span>],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>e</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I8.i5" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i5' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i5.p1" class="ltx_para"> | <div id='Ch2.I8.i5.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">rotate</span><span class="ltx_text ltx_lst_space"> </span>([<span class="ltx_text ltx_lst_identifier">n</span>],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>rotate</span><span class='ltx_text ltx_lst_space'> </span>([<span class='ltx_text ltx_lst_identifier'>n</span>],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
<li id="Ch2.I8.i6" class="ltx_item" style="list-style-type:none;"> | <li id='Ch2.I8.i6' class='ltx_item' style='list-style-type:none;'> |
<span class="ltx_tag ltx_tag_itemize">•</span> | <span class='ltx_tag ltx_tag_itemize'>•</span> |
<div id="Ch2.I8.i6.p1" class="ltx_para"> | <div id='Ch2.I8.i6.p1' class='ltx_para'> |
<p class="ltx_p"><span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">rotate</span><span class="ltx_text ltx_lst_space"> </span>([<span class="ltx_text ltx_lst_identifier">m</span>,<span class="ltx_text ltx_lst_identifier">n</span>],<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">a</span>)</span>?</p> | <p class='ltx_p'><span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>rotate</span><span class='ltx_text ltx_lst_space'> </span>([<span class='ltx_text ltx_lst_identifier'>m</span>,<span class='ltx_text ltx_lst_identifier'>n</span>],<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>a</span>)</span>?</p> |
</div> | </div> |
</li> | </li> |
</ul> | </ul> |
<p class="ltx_p">Can we define the general versions of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">shift</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">rotate</span> | <p class='ltx_p'>Can we define the general versions of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>shift</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>rotate</span> |
as well?</p> | as well?</p> |
</div> | </div> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS1.SSSx4" class="ltx_subsubsection"> | <section id='Ch2.S2.SS1.SSSx4' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Reduction Operations</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Reduction Operations</h6> |
| |
<div id="Ch2.S2.SS1.SSSx4.p1" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx4.p1' class='ltx_para'> |
<p class="ltx_p">The library of standard array operations that comes with the current <span class="ltx_text ltx_font_smallcaps">SaC</span> release also contains a set of functions | <p class='ltx_p'>The library of standard array operations that comes with the current <span class='ltx_text ltx_font_smallcaps'>SaC</span> release also contains a set of functions |
that fold all (scalar) elements of an array into a single one. The most common | that fold all (scalar) elements of an array into a single one. The most common |
ones of these are described here.</p> | ones of these are described here.</p> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx4.p2" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx4.p2' class='ltx_para'> |
<dl id="Ch2.I9" class="ltx_description"> | <dl id='Ch2.I9' class='ltx_description'> |
<dt id="Ch2.I9.ix1" class="ltx_item"><span class="ltx_tag ltx_tag_description">sum(a)</span></dt> | <dt id='Ch2.I9.ix1' class='ltx_item'><span class='ltx_tag ltx_tag_description'>sum(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix1.p1" class="ltx_para"> | <div id='Ch2.I9.ix1.p1' class='ltx_para'> |
<p class="ltx_p">sums up all elements of the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is | <p class='ltx_p'>sums up all elements of the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is |
an empty array, <span class="ltx_text ltx_lstlisting"></span> is returned. | an empty array, <span class='ltx_text ltx_lstlisting'></span> is returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be numerical.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be numerical.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I9.ix2" class="ltx_item"><span class="ltx_tag ltx_tag_description">prod(a)</span></dt> | <dt id='Ch2.I9.ix2' class='ltx_item'><span class='ltx_tag ltx_tag_description'>prod(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix2.p1" class="ltx_para"> | <div id='Ch2.I9.ix2.p1' class='ltx_para'> |
<p class="ltx_p">multiplies all elements of the array <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is | <p class='ltx_p'>multiplies all elements of the array <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is |
an empty array, <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">1</span> is returned. | an empty array, <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>1</span> is returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be numerical.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be numerical.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I9.ix3" class="ltx_item"><span class="ltx_tag ltx_tag_description">all(a)</span></dt> | <dt id='Ch2.I9.ix3' class='ltx_item'><span class='ltx_tag ltx_tag_description'>all(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix3.p1" class="ltx_para"> | <div id='Ch2.I9.ix3.p1' class='ltx_para'> |
<p class="ltx_p">yields <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">true</span>, iff all elements of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> are <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">true</span>. | <p class='ltx_p'>yields <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>true</span>, iff all elements of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> are <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>true</span>. |
If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is an empty array, <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">true</span> is returned. | If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is an empty array, <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>true</span> is returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be boolean.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be boolean.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I9.ix4" class="ltx_item"><span class="ltx_tag ltx_tag_description">any(a)</span></dt> | <dt id='Ch2.I9.ix4' class='ltx_item'><span class='ltx_tag ltx_tag_description'>any(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix4.p1" class="ltx_para"> | <div id='Ch2.I9.ix4.p1' class='ltx_para'> |
<p class="ltx_p">yields <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">true</span>, iff at least one element of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> | <p class='ltx_p'>yields <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>true</span>, iff at least one element of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> |
is <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">true</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is an empty array, <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">false</span> is returned. | is <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>true</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is an empty array, <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>false</span> is returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be boolean.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be boolean.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I9.ix5" class="ltx_item"><span class="ltx_tag ltx_tag_description">maxval(a)</span></dt> | <dt id='Ch2.I9.ix5' class='ltx_item'><span class='ltx_tag ltx_tag_description'>maxval(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix5.p1" class="ltx_para"> | <div id='Ch2.I9.ix5.p1' class='ltx_para'> |
<p class="ltx_p">computes the maximum value of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is | <p class='ltx_p'>computes the maximum value of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is |
an empty array, the minimal number of the according element type is | an empty array, the minimal number of the according element type is |
returned. | returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be numerical.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be numerical.</p> |
</div> | </div> |
</dd> | </dd> |
<dt id="Ch2.I9.ix6" class="ltx_item"><span class="ltx_tag ltx_tag_description">minval(a)</span></dt> | <dt id='Ch2.I9.ix6' class='ltx_item'><span class='ltx_tag ltx_tag_description'>minval(a)</span></dt> |
<dd class="ltx_item"> | <dd class='ltx_item'> |
<div id="Ch2.I9.ix6.p1" class="ltx_para"> | <div id='Ch2.I9.ix6.p1' class='ltx_para'> |
<p class="ltx_p">computes the minimum value of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span>. If <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">a</span> is | <p class='ltx_p'>computes the minimum value of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span>. If <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>a</span> is |
an empty array, the maximal number of the according element type is | an empty array, the maximal number of the according element type is |
returned. | returned. |
<br class="ltx_break"><span class="ltx_text ltx_font_italic">Domain restrictions:</span> the element type has to be numerical.</p> | <br class='ltx_break'><span class='ltx_text ltx_font_italic'>Domain restrictions:</span> the element type has to be numerical.</p> |
</div> | </div> |
</dd> | </dd> |
</dl> | </dl> |
</div> | </div> |
<div id="Ch2.S2.SS1.SSSx4.p3" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx4.p3' class='ltx_para'> |
<p class="ltx_p">A few examples:</p> | <p class='ltx_p'>A few examples:</p> |
</div> | </div> |
<figure id="LST12" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST12' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 12: </span>Reduction Operations</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 12: </span>Reduction Operations</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKCiAg%0AcHJpbnQoc3VtKG1hdCkpOwogIHByaW50KHByb2QodmVjdCkpOwogIHByaW50KGFsbChtYXQgPj0g%0AMSkpOwogIHByaW50KGFueShtYXQgPiAxKSk7CiAgcHJpbnQobWF4dmFsKG1hdCkpOwogIHByaW50%0AKG1pbnZhbChtYXQpKTsKCiAgcmV0dXJuIDA7Cn0=%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKCiAg%0AcHJpbnQoc3VtKG1hdCkpOwogIHByaW50KHByb2QodmVjdCkpOwogIHByaW50KGFsbChtYXQgPj0g%0AMSkpOwogIHByaW50KGFueShtYXQgPiAxKSk7CiAgcHJpbnQobWF4dmFsKG1hdCkpOwogIHByaW50%0AKG1pbnZhbChtYXQpKTsKCiAgcmV0dXJuIDA7Cn0=%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">vect</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+10,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+20]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>vect</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+10,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+20]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">sum</span>(<span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>sum</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">prod</span>(<span class="ltx_text ltx_lst_identifier">vect</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>prod</span>(<span class='ltx_text ltx_lst_identifier'>vect</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">all</span>(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>>=<span class="ltx_text ltx_lst_space"> </span>1)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>all</span>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>>=<span class='ltx_text ltx_lst_space'> </span>1)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">any</span>(<span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>><span class="ltx_text ltx_lst_space"> </span>1)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>any</span>(<span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>><span class='ltx_text ltx_lst_space'> </span>1)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">maxval</span>(<span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>maxval</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">minval</span>(<span class="ltx_text ltx_lst_identifier">mat</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>minval</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS1.SSSx4.p4" class="ltx_para"> | <div id='Ch2.S2.SS1.SSSx4.p4' class='ltx_para'> |
<p class="ltx_p">Most of these examples, again, are fairly self explanatory. | <p class='ltx_p'>Most of these examples, again, are fairly self explanatory. |
However, you may get an idea of the specificational advantages | However, you may get an idea of the specificational advantages |
of shape-invariant programming when having a closer look | of shape-invariant programming when having a closer look |
style of program specifications that results from it.</p> | style of program specifications that results from it.</p> |
</div> | </div> |
<div id="Thmtheorem8" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem8' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 8. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 8. </h6> |
<div id="Thmtheorem8.p1" class="ltx_para"> | <div id='Thmtheorem8.p1' class='ltx_para'> |
<p class="ltx_p">All operations introduced in this part apply to <span class="ltx_text ltx_font_bold">all</span> elements | <p class='ltx_p'>All operations introduced in this part apply to <span class='ltx_text ltx_font_bold'>all</span> elements |
of the array they are applied to. Given the array operations introduced | of the array they are applied to. Given the array operations introduced |
so far, can you specify row-wise or column-wise summations for matrices? | so far, can you specify row-wise or column-wise summations for matrices? |
</section> | </section> |
</section> | </section> |
<section id="Ch2.S2.SS2" class="ltx_subsection"> | <section id='Ch2.S2.SS2' class='ltx_subsection'> |
<h5 class="ltx_title ltx_title_subsection"> | <h5 class='ltx_title ltx_title_subsection'> |
<span class="ltx_tag ltx_tag_subsection">2.2.2 </span>Axis Control Notation</h5> | <span class='ltx_tag ltx_tag_subsection'>2.2.2 </span>Axis Control Notation</h5> |
| |
<div id="Ch2.S2.SS2.p1" class="ltx_para"> | <div id='Ch2.S2.SS2.p1' class='ltx_para'> |
<p class="ltx_p">As can be seen from Exercise <a href="#Thmtheorem8" title="Exercise 8. ‣ Reduction Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">8</span></a>, without further | <p class='ltx_p'>As can be seen from Exercise <a href='#Thmtheorem8' title='Exercise 8. ‣ Reduction Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>8</span></a>, without further |
language support, it is rather difficult | language support, it is rather difficult |
to apply an array operation to certain axes of an array only. | to apply an array operation to certain axes of an array only. |
This section introduces two language constructs of <span class="ltx_text ltx_font_smallcaps">SaC</span> which, | This section introduces two language constructs of <span class='ltx_text ltx_font_smallcaps'>SaC</span> which, |
when taken together, can be used to that effect. | when taken together, can be used to that effect. |
While <em class="ltx_emph">Generalized Selections</em> are convenient for separating individual | While <em class='ltx_emph'>Generalized Selections</em> are convenient for separating individual |
axes of an array, | axes of an array, |
<em class="ltx_emph">Set Notations</em> allow to recombine such axes into a result array | <em class='ltx_emph'>Set Notations</em> allow to recombine such axes into a result array |
after applying arbitrary operations to them. | after applying arbitrary operations to them. |
However, as the two constructs in principle are orthogonal, | However, as the two constructs in principle are orthogonal, |
we introduce them separately before showing how they can be combined | we introduce them separately before showing how they can be combined |
into an instrument for <em class="ltx_emph">Axis Control</em>.</p> | into an instrument for <em class='ltx_emph'>Axis Control</em>.</p> |
</div> | </div> |
<section id="Ch2.S2.SS2.SSSx1" class="ltx_subsubsection"> | <section id='Ch2.S2.SS2.SSSx1' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Generalized Selections</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Generalized Selections</h6> |
| |
<div id="Ch2.S2.SS2.SSSx1.p1" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p1' class='ltx_para'> |
<p class="ltx_p">The selection operation introduced in Section <a href="#Ch2.S2.SS1.SSSx1" title="Basic Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">2.2.1</span></a> does not | <p class='ltx_p'>The selection operation introduced in Section <a href='#Ch2.S2.SS1.SSSx1' title='Basic Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>2.2.1</span></a> does not |
only allow scalar elements but entire subarrays of an array to be selected. | only allow scalar elements but entire subarrays of an array to be selected. |
However, the selection of (non-scalar) subarrays always assumes the given | However, the selection of (non-scalar) subarrays always assumes the given |
transposed first.</p> | transposed first.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p2" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p2' class='ltx_para'> |
<p class="ltx_p">To avoid clumsy notations, <span class="ltx_text ltx_font_smallcaps">SaC</span> provides special syntactical support for | <p class='ltx_p'>To avoid clumsy notations, <span class='ltx_text ltx_font_smallcaps'>SaC</span> provides special syntactical support for |
selecting arbitrary subarrays called <em class="ltx_emph">Generalized Selections</em>. | selecting arbitrary subarrays called <em class='ltx_emph'>Generalized Selections</em>. |
The basic idea is to indicate the axes whose elements are to be selected | The basic idea is to indicate the axes whose elements are to be selected |
entirely by using dot-symbols instead of numerical values within | entirely by using dot-symbols instead of numerical values within |
the index vectors of a selection operation.</p> | the index vectors of a selection operation.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p3" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p3' class='ltx_para'> |
<p class="ltx_p">Note here, that vectors containing dot-symbols are not | <p class='ltx_p'>Note here, that vectors containing dot-symbols are not |
first class citizens of the language, i.e. they can exclusively be specified within | first class citizens of the language, i.e. they can exclusively be specified within |
selection operations directly!</p> | selection operations directly!</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p4" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p4' class='ltx_para'> |
<p class="ltx_p">There are two kinds of dot-symbols, single-dots which refer to a single axis | <p class='ltx_p'>There are two kinds of dot-symbols, single-dots which refer to a single axis |
and triple-dots which refer to as many axes as they are left unspecified within | and triple-dots which refer to as many axes as they are left unspecified within |
a selection. | a selection. |
expression is allowed.</p> | expression is allowed.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p5" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p5' class='ltx_para'> |
<p class="ltx_p">A few examples:</p> | <p class='ltx_p'>A few examples:</p> |
</div> | </div> |
<figure id="LST13" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST13' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 13: </span>Generalized Selections</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 13: </span>Generalized Selections</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBwcmludChtYXRbWzFdXSk7CiAgcHJpbnQobWF0W1sxLC5dXSk7CiAgcHJp%0AbnQobWF0W1sxLC4uLl1dKTsKCiAgcHJpbnQobWF0W1suLDFdXSk7CiAgcHJpbnQobWF0W1suLi4s%0AMV1dKTsKCiAgcHJpbnQobWF0W1sxLC4uLiwxXV0pOwoKICBhcnIzZCA9IFttYXQsIG1hdF07CiAg%0AcHJpbnQoYXJyM2QpOwoKICBwcmludChhcnIzZFtbLiwxXV0pOwogIHByaW50KGFycjNkW1suLi4s%0AMV1dKTsKCiAgcmV0dXJuIDA7Cn0=%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsx%0ALDIsMyw0LDUsNiw3LDgsOV07CgogIG1hdCA9IFt2ZWN0LCB2ZWN0KzEwLCB2ZWN0KzIwXTsKICBw%0AcmludChtYXQpOwoKICBwcmludChtYXRbWzFdXSk7CiAgcHJpbnQobWF0W1sxLC5dXSk7CiAgcHJp%0AbnQobWF0W1sxLC4uLl1dKTsKCiAgcHJpbnQobWF0W1suLDFdXSk7CiAgcHJpbnQobWF0W1suLi4s%0AMV1dKTsKCiAgcHJpbnQobWF0W1sxLC4uLiwxXV0pOwoKICBhcnIzZCA9IFttYXQsIG1hdF07CiAg%0AcHJpbnQoYXJyM2QpOwoKICBwcmludChhcnIzZFtbLiwxXV0pOwogIHByaW50KGFycjNkW1suLi4s%0AMV1dKTsKCiAgcmV0dXJuIDA7Cn0=%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">vect</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+10,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+20]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>vect</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+10,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+20]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[1,.]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[1,.]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[1,…]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[1,…]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[.,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[.,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[…,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[…,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[1,…,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[1,…,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">mat</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>mat</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">22</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>22</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">23</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[.,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>23</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[.,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">24</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[…,1]]); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>24</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[…,1]]); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">25</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>25</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">26</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>26</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">27</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>27</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx1.p6" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p6' class='ltx_para'> |
<p class="ltx_p">The examples in lines 11-13 demonstrate different versions for selecting | <p class='ltx_p'>The examples in lines 11-13 demonstrate different versions for selecting |
the second row of the matrix <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span>. | the second row of the matrix <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span>. |
However, as the rightmost axis is to be selected, a dot-free version | However, as the rightmost axis is to be selected, a dot-free version |
(cf. line 11) suffices for this task. | (cf. line 11) suffices for this task. |
The selection of the second column of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> is shown in lines 15 and 16.</p> | The selection of the second column of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> is shown in lines 15 and 16.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p7" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p7' class='ltx_para'> |
<p class="ltx_p">line 18 demonstrates that the triple-dot notation can | <p class='ltx_p'>line 18 demonstrates that the triple-dot notation can |
also be successfully applied if no axis can be matched at all.</p> | also be successfully applied if no axis can be matched at all.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p8" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p8' class='ltx_para'> |
<p class="ltx_p">The difference between the single-dot and the | <p class='ltx_p'>The difference between the single-dot and the |
triple-dot notation is shown in lines 23 and 24. | triple-dot notation is shown in lines 23 and 24. |
While the selection in line 23 is identical to | While the selection in line 23 is identical to |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">arr3d</span>[[.,1,.]]</span>, the one in line 24 is identical to <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">arr3d</span>[[.,.,1]]</span>.</p> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[.,1,.]]</span>, the one in line 24 is identical to <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[.,.,1]]</span>.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx1.p9" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx1.p9' class='ltx_para'> |
<p class="ltx_p">Only in cases where the number of single-dots plus the number of numerical indices | <p class='ltx_p'>Only in cases where the number of single-dots plus the number of numerical indices |
exceeds the number of axes available, an error message will be generated.</p> | exceeds the number of axes available, an error message will be generated.</p> |
</div> | </div> |
<div id="Thmtheorem9" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem9' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 9. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 9. </h6> |
<div id="Thmtheorem9.p1" class="ltx_para"> | <div id='Thmtheorem9.p1' class='ltx_para'> |
<p class="ltx_p">How can a selection of all elements of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> be specified using | <p class='ltx_p'>How can a selection of all elements of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> be specified using |
generalized selections? Try to find all 9 possible solutions! | generalized selections? Try to find all 9 possible solutions! |
</p> | </p> |
</div> | </div> |
</div> | </div> |
<div id="Thmtheorem10" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem10' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 10. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 10. </h6> |
<div id="Thmtheorem10.p1" class="ltx_para"> | <div id='Thmtheorem10.p1' class='ltx_para'> |
<p class="ltx_p">Referring to Exercise <a href="#Thmtheorem5" title="Exercise 5. ‣ Basic Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">5</span></a>, can this new notation | <p class='ltx_p'>Referring to Exercise <a href='#Thmtheorem5' title='Exercise 5. ‣ Basic Operations ‣ 2.2.1 Standard Array Operations ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>5</span></a>, can this new notation |
be used for selecting “over” empty axis? | be used for selecting “over” empty axis? |
For example, can you specify a selection vector <math id="Thmtheorem10.p1.m1" class="ltx_Math" alttext="{{\langle\textrm{\lstinline 1}}}\rangle" display="inline"><mrow><mo stretchy="false">⟨</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">vec</mtext><mo stretchy="false">⟩</mo></mrow></math>, so that | For example, can you specify a selection vector <math id='Thmtheorem10.p1.m1' class='ltx_Math' alttext='{{\langle\textrm{\lstinline 1}}}\rangle' display='inline'><mrow><mo stretchy='false'>⟨</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>vec</mtext><mo stretchy='false'>⟩</mo></mrow></math>, so that |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">reshape</span>([3,0,5],<span class="ltx_text ltx_lst_space"> </span>[])[<span class="ltx_text ltx_lst_identifier">vec</span>]<span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reshape</span><span class="ltx_text ltx_lst_space"> </span>([3,0],<span class="ltx_text ltx_lst_space"> </span>[])</span> | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>reshape</span>([3,0,5],<span class='ltx_text ltx_lst_space'> </span>[])[<span class='ltx_text ltx_lst_identifier'>vec</span>]<span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reshape</span><span class='ltx_text ltx_lst_space'> </span>([3,0],<span class='ltx_text ltx_lst_space'> </span>[])</span> |
holds?</p> | holds?</p> |
</div> | </div> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS2.SSSx2" class="ltx_subsubsection"> | <section id='Ch2.S2.SS2.SSSx2' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Set Notation</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Set Notation</h6> |
| |
<div id="Ch2.S2.SS2.SSSx2.p1" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p1' class='ltx_para'> |
<p class="ltx_p">The means for composing arrays that have been described so far are rather restricted. | <p class='ltx_p'>The means for composing arrays that have been described so far are rather restricted. |
Apart from element-wise definitions all other operations treat all elements | Apart from element-wise definitions all other operations treat all elements |
uniformly. | uniformly. |
As a consequence, it is difficult to define arrays whose elements differ | As a consequence, it is difficult to define arrays whose elements differ |
depending on their position within the array. | depending on their position within the array. |
The so-called <em class="ltx_emph">set notation</em> facilitates such position dependent array | The so-called <em class='ltx_emph'>set notation</em> facilitates such position dependent array |
definitions. | definitions. |
Essentially, it consists of a mapping from index vectors to elements, taking | Essentially, it consists of a mapping from index vectors to elements, taking |
the general form</p> | the general form</p> |
<table id="Ch2.Ex1" class="ltx_equation ltx_eqn_table"> | <table id='Ch2.Ex1' class='ltx_equation ltx_eqn_table'> |
| |
<tr class="ltx_equation ltx_eqn_row ltx_align_baseline"> | <tr class='ltx_equation ltx_eqn_row ltx_align_baseline'> |
<td class="ltx_eqn_cell ltx_eqn_center_padleft"></td> | <td class='ltx_eqn_cell ltx_eqn_center_padleft'></td> |
<td class="ltx_eqn_cell ltx_align_center"><math id="Ch2.Ex1.m1" class="ltx_Math" alttext="{{{{{{\langle\textrm{\lstinline 1}}}\rangle\ \mathop{\textrm{\lstinline 1}}}}\ % | <td class='ltx_eqn_cell ltx_align_center'><math id='Ch2.Ex1.m1' class='ltx_Math' alttext='{{{{{{\langle\textrm{\lstinline 1}}}\rangle\ \mathop{\textrm{\lstinline 1}}}}\ % |
\langle\textrm{\lstinline 1}}}\rangle" display="block"><mrow><mrow><mo stretchy="false">⟨</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">index_vector</mtext><mo rspace="7.5pt" stretchy="false">⟩</mo></mrow><mo></mo><mrow><mpadded class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting" width="+5pt"><mtext>-></mtext></mpadded><mrow><mo stretchy="false">⟨</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expression</mtext><mo stretchy="false">⟩</mo></mrow></mrow></mrow></math></td> | \langle\textrm{\lstinline 1}}}\rangle' display='block'><mrow><mrow><mo stretchy='false'>⟨</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>index_vector</mtext><mo rspace='7.5pt' stretchy='false'>⟩</mo></mrow><mo></mo><mrow><mpadded class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting' width='+5pt'><mtext>-></mtext></mpadded><mrow><mo stretchy='false'>⟨</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expression</mtext><mo stretchy='false'>⟩</mo></mrow></mrow></mrow></math></td> |
<td class="ltx_eqn_cell ltx_eqn_center_padright"></td> | <td class='ltx_eqn_cell ltx_eqn_center_padright'></td> |
</tr> | </tr> |
</table> | </table> |
<p class="ltx_p">where <math id="Ch2.S2.SS2.SSSx2.p1.m1" class="ltx_Math" alttext="{{\langle\textrm{\lstinline 1}}}\rangle" display="inline"><mrow><mo stretchy="false">⟨</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">index_vector</mtext><mo stretchy="false">⟩</mo></mrow></math> either is a variable or a vector of variables | <p class='ltx_p'>where <math id='Ch2.S2.SS2.SSSx2.p1.m1' class='ltx_Math' alttext='{{\langle\textrm{\lstinline 1}}}\rangle' display='inline'><mrow><mo stretchy='false'>⟨</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>index_vector</mtext><mo stretchy='false'>⟩</mo></mrow></math> either is a variable or a vector of variables |
and <math id="Ch2.S2.SS2.SSSx2.p1.m2" class="ltx_Math" alttext="{{\langle\textrm{\lstinline 1}}}\rangle" display="inline"><mrow><mo stretchy="false">⟨</mo><mtext class="ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">expression</mtext><mo stretchy="false">⟩</mo></mrow></math> is a <span class="ltx_text ltx_font_smallcaps">SaC</span> expression that refers to | and <math id='Ch2.S2.SS2.SSSx2.p1.m2' class='ltx_Math' alttext='{{\langle\textrm{\lstinline 1}}}\rangle' display='inline'><mrow><mo stretchy='false'>⟨</mo><mtext class='ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>expression</mtext><mo stretchy='false'>⟩</mo></mrow></math> is a <span class='ltx_text ltx_font_smallcaps'>SaC</span> expression that refers to |
the index vector or its components and defines the | the index vector or its components and defines the |
individual array elements. | individual array elements. |
by the expression given and, thus, it is not specified explicitly.</p> | by the expression given and, thus, it is not specified explicitly.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx2.p2" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p2' class='ltx_para'> |
<p class="ltx_p ltx_align_center"> | <p class='ltx_p ltx_align_center'> |
| |
<span class="ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle" style="width:390.3pt;"> | <span class='ltx_inline-block ltx_minipage ltx_align_middle ltx_framed_rectangle' style='width:390.3pt;'> |
<span class="ltx_p"><span class="ltx_text ltx_font_bold">A note for language design freaks:</span></span> | <span class='ltx_p'><span class='ltx_text ltx_font_bold'>A note for language design freaks:</span></span> |
<span class="ltx_p"><span class="ltx_text ltx_font_italic">You may wonder why we restrict the expressiveness of the set notation | <span class='ltx_p'><span class='ltx_text ltx_font_italic'>You may wonder why we restrict the expressiveness of the set notation |
by relying on compiler driven range detection rather than an explicit | by relying on compiler driven range detection rather than an explicit |
range specification. | range specification. |
the capabilities of the set notation suffice whereas an explicit specification | the capabilities of the set notation suffice whereas an explicit specification |
of ranges would obfuscate the code.</span></span> | of ranges would obfuscate the code.</span></span> |
<span class="ltx_p"><span class="ltx_text ltx_font_italic">Furthermore, as you will see in Chapter <a href="#Ch4" title="Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">4</span></a>, <span class="ltx_text ltx_font_smallcaps">SaC</span> provides a | <span class='ltx_p'><span class='ltx_text ltx_font_italic'>Furthermore, as you will see in Chapter <a href='#Ch4' title='Chapter 4 With-Loops ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>4</span></a>, <span class='ltx_text ltx_font_smallcaps'>SaC</span> provides a |
more versatile language construct for defining arrays. | more versatile language construct for defining arrays. |
However, the expressiveness of that construct comes for quite some | However, the expressiveness of that construct comes for quite some |
</p> | </p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx2.p3" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p3' class='ltx_para'> |
<p class="ltx_p">Let us have a look at some examples:</p> | <p class='ltx_p'>Let us have a look at some examples:</p> |
</div> | </div> |
<figure id="LST14" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST14' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 14: </span>Basic Set Notation</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 14: </span>Basic Set Notation</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzLDQsNSw2LDcsOCw5XTsKCiAgbWF0ID0ge1tpXSAtPiB2ZWN0W1tpXV0qMTArdmVjdH07%0ACiAgcHJpbnQobWF0KTsKCiAgbWF0X2luYyA9IHtpdiAtPiBtYXRbaXZdICsgMX07CiAgcHJpbnQo%0AbWF0X2luYyk7CgogIG1hdF90cmFucyA9IHtbaSxqXSAtPiBtYXRbW2osaV1dfTsKICBwcmludCht%0AYXRfdHJhbnMpOwoKICBtYXRfZGlhZyA9IHtbaSxqXSAtPiB3aGVyZShpID09IGogLCBtYXRbW2ks%0Aal1dICwgMCl9OwogIHByaW50KG1hdF9kaWFnKTsKCiAgcmV0dXJuIDA7Cn0=%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzLDQsNSw2LDcsOCw5XTsKCiAgbWF0ID0ge1tpXSAtPiB2ZWN0W1tpXV0qMTArdmVjdH07%0ACiAgcHJpbnQobWF0KTsKCiAgbWF0X2luYyA9IHtpdiAtPiBtYXRbaXZdICsgMX07CiAgcHJpbnQo%0AbWF0X2luYyk7CgogIG1hdF90cmFucyA9IHtbaSxqXSAtPiBtYXRbW2osaV1dfTsKICBwcmludCht%0AYXRfdHJhbnMpOwoKICBtYXRfZGlhZyA9IHtbaSxqXSAtPiB3aGVyZShpID09IGogLCBtYXRbW2ks%0Aal1dICwgMCl9OwogIHByaW50KG1hdF9kaWFnKTsKCiAgcmV0dXJuIDA7Cn0=%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*10+<span class="ltx_text ltx_lst_identifier">vect</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*10+<span class='ltx_text ltx_lst_identifier'>vect</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat_inc</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{<span class="ltx_text ltx_lst_identifier">iv</span><span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[<span class="ltx_text ltx_lst_identifier">iv</span>]<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span>1}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat_inc</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{<span class='ltx_text ltx_lst_identifier'>iv</span><span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[<span class='ltx_text ltx_lst_identifier'>iv</span>]<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span>1}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat_inc</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat_inc</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat_trans</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[j,<span class="ltx_text ltx_lst_identifier">i</span>]]}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat_trans</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[j,<span class='ltx_text ltx_lst_identifier'>i</span>]]}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat_trans</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat_trans</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat_diag</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">where</span>(<span class="ltx_text ltx_lst_identifier">i</span><span class="ltx_text ltx_lst_space"> </span>==<span class="ltx_text ltx_lst_space"> </span>j<span class="ltx_text ltx_lst_space"> </span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,j]]<span class="ltx_text ltx_lst_space"> </span>,<span class="ltx_text ltx_lst_space"> </span>0)}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat_diag</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>where</span>(<span class='ltx_text ltx_lst_identifier'>i</span><span class='ltx_text ltx_lst_space'> </span>==<span class='ltx_text ltx_lst_space'> </span>j<span class='ltx_text ltx_lst_space'> </span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,j]]<span class='ltx_text ltx_lst_space'> </span>,<span class='ltx_text ltx_lst_space'> </span>0)}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat_diag</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat_diag</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx2.p4" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p4' class='ltx_para'> |
<p class="ltx_p">The set notation in line 8 defines a vector whose components | <p class='ltx_p'>The set notation in line 8 defines a vector whose components |
at position <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[<span class="ltx_text ltx_lst_identifier">i</span>]</span> are vectors that are computed from adding | at position <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[<span class='ltx_text ltx_lst_identifier'>i</span>]</span> are vectors that are computed from adding |
a multiple of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">1</span> to the vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">vect</span>. | a multiple of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>1</span> to the vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>vect</span>. |
The legal range of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</span> is derived from the selection | The legal range of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</span> is derived from the selection |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]</span> yielding in fact a matrix with shape <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[10,10]</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]</span> yielding in fact a matrix with shape <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[10,10]</span>. |
An explicit element-wise increment operation is specified in line 11. | An explicit element-wise increment operation is specified in line 11. |
Since the operation does not need to refer to individual axes a | Since the operation does not need to refer to individual axes a |
variable <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">iv</span> is used for the entire index vector rather than | variable <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>iv</span> is used for the entire index vector rather than |
having variables for individual index components. | having variables for individual index components. |
Line 14 shows how the matrix can be transposed, and line 17 | Line 14 shows how the matrix can be transposed, and line 17 |
changes all non-diagonal elements to <span class="ltx_text ltx_lstlisting"></span>.</p> | changes all non-diagonal elements to <span class='ltx_text ltx_lstlisting'></span>.</p> |
</div> | </div> |
<div id="Thmtheorem11" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem11' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 11. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 11. </h6> |
<div id="Thmtheorem11.p1" class="ltx_para"> | <div id='Thmtheorem11.p1' class='ltx_para'> |
<p class="ltx_p">Which of these operations can be expressed in terms of the array operations | <p class='ltx_p'>Which of these operations can be expressed in terms of the array operations |
defined so far?</p> | defined so far?</p> |
</div> | </div> |
</div> | </div> |
<div id="Thmtheorem12" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem12' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 12. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 12. </h6> |
<div id="Thmtheorem12.p1" class="ltx_para"> | <div id='Thmtheorem12.p1' class='ltx_para'> |
<p class="ltx_p">What results do you expect if <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> is an empty matrix, e.g. <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">reshape</span>([10,0],<span class="ltx_text ltx_lst_space"> </span>[])</span>?</p> | <p class='ltx_p'>What results do you expect if <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> is an empty matrix, e.g. <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>reshape</span>([10,0],<span class='ltx_text ltx_lst_space'> </span>[])</span>?</p> |
</div> | </div> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx2.p5" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p5' class='ltx_para'> |
<p class="ltx_p">As we can see from the set notation in line 8, non-scalar expressions | <p class='ltx_p'>As we can see from the set notation in line 8, non-scalar expressions |
within the set notation per default constitute the inner axes of the | within the set notation per default constitute the inner axes of the |
result array. | result array. |
axes that should constitute the result axis.</p> | axes that should constitute the result axis.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx2.p6" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p6' class='ltx_para'> |
<p class="ltx_p">A few examples:</p> | <p class='ltx_p'>A few examples:</p> |
</div> | </div> |
<figure id="LST15" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST15' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 15: </span>Advanced Set Notation</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 15: </span>Advanced Set Notation</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgbWF0ID0ge1suLGldIC0+IHZlY3RbW2ldXSo0ICsgdmVjdH07CiAgcHJpbnQo%0AbWF0KTsKCiAgYXJyM2QgPSB7W2ldIC0+IHZlY3RbW2ldXSoxNiArIG1hdH07CiAgcHJpbnQoYXJy%0AM2QpOwoKICBhcnIzZCA9IHtbLiwuLGldIC0+IHZlY3RbW2ldXSoxNiArIG1hdH07CiAgcHJpbnQo%0AYXJyM2QpOwoKICBhcnIzZCA9IHtbLixpXSAtPiB2ZWN0W1tpXV0qMTYgKyBtYXR9OwogIHByaW50%0AKGFycjNkKTsKCiAgcmV0dXJuIDA7Cn0=%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgbWF0ID0ge1suLGldIC0+IHZlY3RbW2ldXSo0ICsgdmVjdH07CiAgcHJpbnQo%0AbWF0KTsKCiAgYXJyM2QgPSB7W2ldIC0+IHZlY3RbW2ldXSoxNiArIG1hdH07CiAgcHJpbnQoYXJy%0AM2QpOwoKICBhcnIzZCA9IHtbLiwuLGldIC0+IHZlY3RbW2ldXSoxNiArIG1hdH07CiAgcHJpbnQo%0AYXJyM2QpOwoKICBhcnIzZCA9IHtbLixpXSAtPiB2ZWN0W1tpXV0qMTYgKyBtYXR9OwogIHByaW50%0AKGFycjNkKTsKCiAgcmV0dXJuIDA7Cn0=%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,1,2,3]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,1,2,3]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[.,<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*4<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[.,<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*4<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*16<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*16<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[.,.,<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*16<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[.,.,<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*16<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[.,<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*16<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[.,<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*16<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx2.p7" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx2.p7' class='ltx_para'> |
<p class="ltx_p">These examples show how the result of evaluating the expression on the right of the arrow can be directed into any axes of the overall result array. | <p class='ltx_p'>These examples show how the result of evaluating the expression on the right of the arrow can be directed into any axes of the overall result array. |
As can be seen in line 17, the axes of the expressions can even be put into | As can be seen in line 17, the axes of the expressions can even be put into |
non-adjacent axes of the result.</p> | non-adjacent axes of the result.</p> |
</div> | </div> |
<div id="Thmtheorem13" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem13' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 13. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 13. </h6> |
<div id="Thmtheorem13.p1" class="ltx_para"> | <div id='Thmtheorem13.p1' class='ltx_para'> |
<p class="ltx_p">The ‘.’ symbol in the set notation allows us to direct a computation | <p class='ltx_p'>The ‘.’ symbol in the set notation allows us to direct a computation |
to any axes of the result. This is identical to first putting the result | to any axes of the result. This is identical to first putting the result |
into the innermost axes and then transposing the result. | into the innermost axes and then transposing the result. |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS2.SSSx3" class="ltx_subsubsection"> | <section id='Ch2.S2.SS2.SSSx3' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Axis Control</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Axis Control</h6> |
| |
<div id="Ch2.S2.SS2.SSSx3.p1" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p1' class='ltx_para'> |
<p class="ltx_p">Although generalized selections and the set notation per se can be useful, | <p class='ltx_p'>Although generalized selections and the set notation per se can be useful, |
their real potential shows when they are used in combination. | their real potential shows when they are used in combination. |
Together, they constitute means to control the axes a given operation | Together, they constitute means to control the axes a given operation |
the results to the overall array.</p> | the results to the overall array.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx3.p2" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p2' class='ltx_para'> |
<p class="ltx_p">For example, we can now easily sum up the individual rows or columns | <p class='ltx_p'>For example, we can now easily sum up the individual rows or columns |
of a matrix:</p> | of a matrix:</p> |
</div> | </div> |
<figure id="LST16" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST16' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 16: </span>Axis Control: sum</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 16: </span>Axis Control: sum</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzLDQsNSw2LDcsOCw5XTsKCiAgbWF0ID0ge1suLGldIC0+IHZlY3RbW2ldXSoxMCt2ZWN0%0AfTsKICBwcmludChtYXQpOwoKICBzdW1fcm93cyA9IHtbaV0gLT4gc3VtKG1hdFtbaV1dKX07CiAg%0AcHJpbnQoc3VtX3Jvd3MpOwoKICBzdW1fY29scyA9IHtbaV0gLT4gc3VtKCBtYXRbWy4saV1dKX07%0ACiAgcHJpbnQoc3VtX2NvbHMpOwoKICByZXR1cm4gMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzLDQsNSw2LDcsOCw5XTsKCiAgbWF0ID0ge1suLGldIC0+IHZlY3RbW2ldXSoxMCt2ZWN0%0AfTsKICBwcmludChtYXQpOwoKICBzdW1fcm93cyA9IHtbaV0gLT4gc3VtKG1hdFtbaV1dKX07CiAg%0AcHJpbnQoc3VtX3Jvd3MpOwoKICBzdW1fY29scyA9IHtbaV0gLT4gc3VtKCBtYXRbWy4saV1dKX07%0ACiAgcHJpbnQoc3VtX2NvbHMpOwoKICByZXR1cm4gMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,1,2,3,4,5,6,7,8,9]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,1,2,3,4,5,6,7,8,9]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[.,<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*10+<span class="ltx_text ltx_lst_identifier">vect</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[.,<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*10+<span class='ltx_text ltx_lst_identifier'>vect</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sum_rows</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sum</span>(<span class="ltx_text ltx_lst_identifier">mat</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sum_rows</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sum</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">sum_rows</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>sum_rows</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sum_cols</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sum</span>(<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[.,<span class="ltx_text ltx_lst_identifier">i</span>]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sum_cols</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sum</span>(<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[.,<span class='ltx_text ltx_lst_identifier'>i</span>]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">sum_cols</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>sum_cols</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx3.p3" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p3' class='ltx_para'> |
<p class="ltx_p">Reduction operations, in general, are prone to axis control, as they | <p class='ltx_p'>Reduction operations, in general, are prone to axis control, as they |
often need to be applied to certain | often need to be applied to certain |
particular axes rather than entire arrays. | particular axes rather than entire arrays. |
Other popular examples are the maximum (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">maxval</span>) and | Other popular examples are the maximum (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>maxval</span>) and |
minimum (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">minval</span>) operations:</p> | minimum (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>minval</span>) operations:</p> |
</div> | </div> |
<figure id="LST17" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST17' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 17: </span>Axis Control: max</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 17: </span>Axis Control: max</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgYXJyM2QgPSB7W2ksal0gLT4gdmVjdFtbaV1dKjQgKyB2ZWN0W1tqXV0qMTYg%0AKyB2ZWN0fTsKICBwcmludChhcnIzZCk7CgogIG1heF9pbm5lcl92ZWN0cyA9IHtbaSxqXSAtPiBt%0AYXh2YWwoYXJyM2RbW2ksal1dKX07CiAgcHJpbnQobWF4X2lubmVyX3ZlY3RzKTsKCiAgbWF4X2lu%0AbmVyX2FycmF5cyA9IHtbaV0gLT4gbWF4dmFsKGFycjNkW1tpXV0pfTsKICBwcmludChtYXhfaW5u%0AZXJfYXJyYXlzKTsKCiAgbWF4X291dGVyX2FycmF5cyA9IHtbaV0gLT4gbWF4dmFsKGFycjNkW1su%0ALC4saV1dKX07CiAgcHJpbnQobWF4X291dGVyX2FycmF5cyk7CgogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgYXJyM2QgPSB7W2ksal0gLT4gdmVjdFtbaV1dKjQgKyB2ZWN0W1tqXV0qMTYg%0AKyB2ZWN0fTsKICBwcmludChhcnIzZCk7CgogIG1heF9pbm5lcl92ZWN0cyA9IHtbaSxqXSAtPiBt%0AYXh2YWwoYXJyM2RbW2ksal1dKX07CiAgcHJpbnQobWF4X2lubmVyX3ZlY3RzKTsKCiAgbWF4X2lu%0AbmVyX2FycmF5cyA9IHtbaV0gLT4gbWF4dmFsKGFycjNkW1tpXV0pfTsKICBwcmludChtYXhfaW5u%0AZXJfYXJyYXlzKTsKCiAgbWF4X291dGVyX2FycmF5cyA9IHtbaV0gLT4gbWF4dmFsKGFycjNkW1su%0ALC4saV1dKX07CiAgcHJpbnQobWF4X291dGVyX2FycmF5cyk7CgogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,1,2,3]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,1,2,3]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*4<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[j]]*16<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*4<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[j]]*16<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">max_inner_vects</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">maxval</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,j]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>max_inner_vects</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>maxval</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,j]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">max_inner_vects</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>max_inner_vects</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">max_inner_arrays</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">maxval</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>max_inner_arrays</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>maxval</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">max_inner_arrays</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>max_inner_arrays</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">max_outer_arrays</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">maxval</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[.,.,<span class="ltx_text ltx_lst_identifier">i</span>]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>max_outer_arrays</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>maxval</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[.,.,<span class='ltx_text ltx_lst_identifier'>i</span>]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">max_outer_arrays</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>max_outer_arrays</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">21</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>21</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx3.p4" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p4' class='ltx_para'> |
<p class="ltx_p">In line 8, we directly generate a 3 dimensional array from the vector <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">vect</span>. | <p class='ltx_p'>In line 8, we directly generate a 3 dimensional array from the vector <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>vect</span>. |
Lines 11, 14, and 17 compute maxima within different slices of that array. | Lines 11, 14, and 17 compute maxima within different slices of that array. |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">max_inner_vects</span> is a matrix containing the maxima within the innermost vectors, | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>max_inner_vects</span> is a matrix containing the maxima within the innermost vectors, |
i.e. the 3-dimensional array is considered a matrix of vectors whose maximum | i.e. the 3-dimensional array is considered a matrix of vectors whose maximum |
values are computed. | values are computed. |
For <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">max_inner_arrays</span>, the array is considered a vector of matrices; it contains | For <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>max_inner_arrays</span>, the array is considered a vector of matrices; it contains |
the maximum values of these subarrays. | the maximum values of these subarrays. |
The last example demonstrates, that outer dimensions can be considered for | The last example demonstrates, that outer dimensions can be considered for |
reduction as well.</p> | reduction as well.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx3.p5" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p5' class='ltx_para'> |
<p class="ltx_p">Further demand for axis control arises in the context of array operations | <p class='ltx_p'>Further demand for axis control arises in the context of array operations |
that are dedicated to one fixed axis (usually the outermost one) and that need | that are dedicated to one fixed axis (usually the outermost one) and that need |
to be applied to another one. | to be applied to another one. |
Examples for this situation are the concatenation operation (<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">++</span>) | Examples for this situation are the concatenation operation (<span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>++</span>) |
and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reverse</span>:</p> | and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reverse</span>:</p> |
</div> | </div> |
<figure id="LST18" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST18' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 18: </span>Axis Control: ++, reverse</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 18: </span>Axis Control: ++, reverse</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgYXJyM2QgPSB7W2ksal0gLT4gdmVjdFtbaV1dKjQgKyB2ZWN0W1tqXV0qMTYg%0AKyB2ZWN0fTsKICBwcmludChhcnIzZCk7CgogIHByaW50KGFycjNkICsrIGFycjNkKTsKICBwcmlu%0AdCh7W2ldIC0+IGFycjNkW1tpXV0gKysgYXJyM2RbW2ldXX0pOwogIHByaW50KHtbaSxqXSAtPiBh%0AcnIzZFtbaSxqXV0gKysgYXJyM2RbW2ksal1dfSk7CgogIHByaW50KHJldmVyc2UoIGFycjNkKSk7%0ACiAgcHJpbnQoeyBbaV0gLT4gcmV2ZXJzZShhcnIzZFtbaV1dKX0pOwogIHByaW50KHsgW2ksal0g%0ALT4gcmV2ZXJzZShhcnIzZFtbaSxqXV0pfSk7CgogIHJldHVybiAwOwp9%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgdmVjdCA9IFsw%0ALDEsMiwzXTsKCiAgYXJyM2QgPSB7W2ksal0gLT4gdmVjdFtbaV1dKjQgKyB2ZWN0W1tqXV0qMTYg%0AKyB2ZWN0fTsKICBwcmludChhcnIzZCk7CgogIHByaW50KGFycjNkICsrIGFycjNkKTsKICBwcmlu%0AdCh7W2ldIC0+IGFycjNkW1tpXV0gKysgYXJyM2RbW2ldXX0pOwogIHByaW50KHtbaSxqXSAtPiBh%0AcnIzZFtbaSxqXV0gKysgYXJyM2RbW2ksal1dfSk7CgogIHByaW50KHJldmVyc2UoIGFycjNkKSk7%0ACiAgcHJpbnQoeyBbaV0gLT4gcmV2ZXJzZShhcnIzZFtbaV1dKX0pOwogIHByaW50KHsgW2ksal0g%0ALT4gcmV2ZXJzZShhcnIzZFtbaSxqXV0pfSk7CgogIHJldHVybiAwOwp9%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[0,1,2,3]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[0,1,2,3]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]*4<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>[[j]]*16<span class="ltx_text ltx_lst_space"> </span>+<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]*4<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>[[j]]*16<span class='ltx_text ltx_lst_space'> </span>+<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span><span class="ltx_text ltx_lst_space"> </span>++<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span><span class='ltx_text ltx_lst_space'> </span>++<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>({[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]<span class="ltx_text ltx_lst_space"> </span>++<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]]}); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>({[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]<span class='ltx_text ltx_lst_space'> </span>++<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]]}); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>({[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,j]]<span class="ltx_text ltx_lst_space"> </span>++<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,j]]}); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>({[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,j]]<span class='ltx_text ltx_lst_space'> </span>++<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,j]]}); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">reverse</span>(<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">arr3d</span>)); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>reverse</span>(<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>arr3d</span>)); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>({<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">i</span>]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reverse</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>]])}); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>({<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>i</span>]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reverse</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>]])}); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">17</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>({<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">reverse</span>(<span class="ltx_text ltx_lst_identifier">arr3d</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,j]])}); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>17</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>({<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>reverse</span>(<span class='ltx_text ltx_lst_identifier'>arr3d</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,j]])}); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">18</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>18</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">19</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>19</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">20</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>20</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS2.SSSx3.p6" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p6' class='ltx_para'> |
<p class="ltx_p">Line 11 shows a standard application of the concatenation of two arrays. | <p class='ltx_p'>Line 11 shows a standard application of the concatenation of two arrays. |
It affects the outermost axis only, resulting in an array of shape | It affects the outermost axis only, resulting in an array of shape |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">[8,<span class="ltx_text ltx_lst_space"> </span>0,<span class="ltx_text ltx_lst_space"> </span>0]</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>[8,<span class='ltx_text ltx_lst_space'> </span>0,<span class='ltx_text ltx_lst_space'> </span>0]</span>. |
The two subsequent lines show, how to apply concatenation to other axis. | The two subsequent lines show, how to apply concatenation to other axis. |
Essentially, the selections on the right hand sides select the sub expressions to | Essentially, the selections on the right hand sides select the sub expressions to |
subarrays back together again.</p> | subarrays back together again.</p> |
</div> | </div> |
<div id="Ch2.S2.SS2.SSSx3.p7" class="ltx_para"> | <div id='Ch2.S2.SS2.SSSx3.p7' class='ltx_para'> |
<p class="ltx_p">The examples in lines 15-17 show the same exercise for the operation | <p class='ltx_p'>The examples in lines 15-17 show the same exercise for the operation |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">reverse</span> which reverses the order of the elements within an array | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>reverse</span> which reverses the order of the elements within an array |
with respect to the outermost axis.</p> | with respect to the outermost axis.</p> |
</div> | </div> |
<div id="Thmtheorem14" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem14' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 14. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 14. </h6> |
<div id="Thmtheorem14.p1" class="ltx_para"> | <div id='Thmtheorem14.p1' class='ltx_para'> |
<p class="ltx_p">The operation <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">take</span> is defined in a way that ensures inner axes | <p class='ltx_p'>The operation <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>take</span> is defined in a way that ensures inner axes |
to be taken completely in case the take vector does not provide enough | to be taken completely in case the take vector does not provide enough |
entities for all axes. | entities for all axes. |
How can <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">take</span> be applied to an array so that the outermost axis | How can <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>take</span> be applied to an array so that the outermost axis |
remains untouched and the selections are applied to inner axes, starting at the | remains untouched and the selections are applied to inner axes, starting at the |
second one? (You may assume, that the take vector has fewer elements | second one? (You may assume, that the take vector has fewer elements |
</div> | </div> |
</div> | </div> |
<div id="Thmtheorem15" class="ltx_theorem ltx_theorem_theorem"> | <div id='Thmtheorem15' class='ltx_theorem ltx_theorem_theorem'> |
<h6 class="ltx_title ltx_runin ltx_font_bold ltx_title_theorem">Exercise 15. </h6> | <h6 class='ltx_title ltx_runin ltx_font_bold ltx_title_theorem'>Exercise 15. </h6> |
<div id="Thmtheorem15.p1" class="ltx_para"> | <div id='Thmtheorem15.p1' class='ltx_para'> |
<p class="ltx_p">Can you merge two vectors of identical length element-wise? | <p class='ltx_p'>Can you merge two vectors of identical length element-wise? |
Extend your solution in a way that permits merging <math id="Thmtheorem15.p1.m1" class="ltx_Math" alttext="n" display="inline"><mi>n</mi></math>-dimensional | Extend your solution in a way that permits merging <math id='Thmtheorem15.p1.m1' class='ltx_Math' alttext='n' display='inline'><mi>n</mi></math>-dimensional |
arrays on the outermost axis.</p> | arrays on the outermost axis.</p> |
</div> | </div> |
</section> | </section> |
</section> | </section> |
<section id="Ch2.S2.SS3" class="ltx_subsection"> | <section id='Ch2.S2.SS3' class='ltx_subsection'> |
<h5 class="ltx_title ltx_title_subsection"> | <h5 class='ltx_title ltx_title_subsection'> |
<span class="ltx_tag ltx_tag_subsection">2.2.3 </span>Putting it all Together</h5> | <span class='ltx_tag ltx_tag_subsection'>2.2.3 </span>Putting it all Together</h5> |
| |
<div id="Ch2.S2.SS3.p1" class="ltx_para"> | <div id='Ch2.S2.SS3.p1' class='ltx_para'> |
<p class="ltx_p">The array operations presented so far constitute a substantial | <p class='ltx_p'>The array operations presented so far constitute a substantial |
subset of the functionality that is provided by array programming | subset of the functionality that is provided by array programming |
languages such as <span class="ltx_text ltx_font_smallcaps">APL</span>. | languages such as <span class='ltx_text ltx_font_smallcaps'>APL</span>. |
When orchestrated properly, these suffice to express rather complex | When orchestrated properly, these suffice to express rather complex |
array operations very concisely. | array operations very concisely. |
power: matrix product and relaxation.</p> | power: matrix product and relaxation.</p> |
</div> | </div> |
<section id="Ch2.S2.SS3.SSSx1" class="ltx_subsubsection"> | <section id='Ch2.S2.SS3.SSSx1' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Matrix Product</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Matrix Product</h6> |
| |
<div id="Ch2.S2.SS3.SSSx1.p1" class="ltx_para"> | <div id='Ch2.S2.SS3.SSSx1.p1' class='ltx_para'> |
<p class="ltx_p">The matrix product of two matrices <math id="Ch2.S2.SS3.SSSx1.p1.m1" class="ltx_Math" alttext="A" display="inline"><mi>A</mi></math> and <math id="Ch2.S2.SS3.SSSx1.p1.m2" class="ltx_Math" alttext="B" display="inline"><mi>B</mi></math> (denoted by <math id="Ch2.S2.SS3.SSSx1.p1.m3" class="ltx_Math" alttext="A\odot B" display="inline"><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow></math>) is defined | <p class='ltx_p'>The matrix product of two matrices <math id='Ch2.S2.SS3.SSSx1.p1.m1' class='ltx_Math' alttext='A' display='inline'><mi>A</mi></math> and <math id='Ch2.S2.SS3.SSSx1.p1.m2' class='ltx_Math' alttext='B' display='inline'><mi>B</mi></math> (denoted by <math id='Ch2.S2.SS3.SSSx1.p1.m3' class='ltx_Math' alttext='A\odot B' display='inline'><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow></math>) is defined |
as follows:</p> | as follows:</p> |
</div> | </div> |
<div id="Ch2.S2.SS3.SSSx1.p2" class="ltx_para"> | <div id='Ch2.S2.SS3.SSSx1.p2' class='ltx_para'> |
<p class="ltx_p">Provided <math id="Ch2.S2.SS3.SSSx1.p2.m1" class="ltx_Math" alttext="A" display="inline"><mi>A</mi></math> has as many columns as <math id="Ch2.S2.SS3.SSSx1.p2.m2" class="ltx_Math" alttext="B" display="inline"><mi>B</mi></math> has rows, the result of <math id="Ch2.S2.SS3.SSSx1.p2.m3" class="ltx_Math" alttext="A\odot B" display="inline"><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow></math> | <p class='ltx_p'>Provided <math id='Ch2.S2.SS3.SSSx1.p2.m1' class='ltx_Math' alttext='A' display='inline'><mi>A</mi></math> has as many columns as <math id='Ch2.S2.SS3.SSSx1.p2.m2' class='ltx_Math' alttext='B' display='inline'><mi>B</mi></math> has rows, the result of <math id='Ch2.S2.SS3.SSSx1.p2.m3' class='ltx_Math' alttext='A\odot B' display='inline'><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow></math> |
has as many rows as <math id="Ch2.S2.SS3.SSSx1.p2.m4" class="ltx_Math" alttext="A" display="inline"><mi>A</mi></math> and as many columns as <math id="Ch2.S2.SS3.SSSx1.p2.m5" class="ltx_Math" alttext="B" display="inline"><mi>B</mi></math>. Each element | has as many rows as <math id='Ch2.S2.SS3.SSSx1.p2.m4' class='ltx_Math' alttext='A' display='inline'><mi>A</mi></math> and as many columns as <math id='Ch2.S2.SS3.SSSx1.p2.m5' class='ltx_Math' alttext='B' display='inline'><mi>B</mi></math>. Each element |
<math id="Ch2.S2.SS3.SSSx1.p2.m6" class="ltx_Math" alttext="{(A\odot B)}_{i,j}" display="inline"><msub><mrow><mo stretchy="false">(</mo><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow><mo stretchy="false">)</mo></mrow><mrow><mi>i</mi><mo>,</mo><mi>j</mi></mrow></msub></math> is defined as the scalar product of the <math id="Ch2.S2.SS3.SSSx1.p2.m7" class="ltx_Math" alttext="i" display="inline"><mi>i</mi></math>-th row of <math id="Ch2.S2.SS3.SSSx1.p2.m8" class="ltx_Math" alttext="A" display="inline"><mi>A</mi></math> | <math id='Ch2.S2.SS3.SSSx1.p2.m6' class='ltx_Math' alttext='{(A\odot B)}_{i,j}' display='inline'><msub><mrow><mo stretchy='false'>(</mo><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow><mo stretchy='false'>)</mo></mrow><mrow><mi>i</mi><mo>,</mo><mi>j</mi></mrow></msub></math> is defined as the scalar product of the <math id='Ch2.S2.SS3.SSSx1.p2.m7' class='ltx_Math' alttext='i' display='inline'><mi>i</mi></math>-th row of <math id='Ch2.S2.SS3.SSSx1.p2.m8' class='ltx_Math' alttext='A' display='inline'><mi>A</mi></math> |
and the <math id="Ch2.S2.SS3.SSSx1.p2.m9" class="ltx_Math" alttext="j" display="inline"><mi>j</mi></math>-th column of <math id="Ch2.S2.SS3.SSSx1.p2.m10" class="ltx_Math" alttext="B" display="inline"><mi>B</mi></math>, i.e. we have | and the <math id='Ch2.S2.SS3.SSSx1.p2.m9' class='ltx_Math' alttext='j' display='inline'><mi>j</mi></math>-th column of <math id='Ch2.S2.SS3.SSSx1.p2.m10' class='ltx_Math' alttext='B' display='inline'><mi>B</mi></math>, i.e. we have |
<math id="Ch2.S2.SS3.SSSx1.p2.m11" class="ltx_Math" alttext="{(A\odot B)}_{i,j}=\sum_{k}A_{i,k}*B_{k,j}" display="inline"><mrow><msub><mrow><mo stretchy="false">(</mo><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow><mo stretchy="false">)</mo></mrow><mrow><mi>i</mi><mo>,</mo><mi>j</mi></mrow></msub><mo>=</mo><mrow><msub><mo largeop="true" symmetric="true">∑</mo><mi>k</mi></msub><mrow><msub><mi>A</mi><mrow><mi>i</mi><mo>,</mo><mi>k</mi></mrow></msub><mo>*</mo><msub><mi>B</mi><mrow><mi>k</mi><mo>,</mo><mi>j</mi></mrow></msub></mrow></mrow></mrow></math>.</p> | <math id='Ch2.S2.SS3.SSSx1.p2.m11' class='ltx_Math' alttext='{(A\odot B)}_{i,j}=\sum_{k}A_{i,k}*B_{k,j}' display='inline'><mrow><msub><mrow><mo stretchy='false'>(</mo><mrow><mi>A</mi><mo>⊙</mo><mi>B</mi></mrow><mo stretchy='false'>)</mo></mrow><mrow><mi>i</mi><mo>,</mo><mi>j</mi></mrow></msub><mo>=</mo><mrow><msub><mo largeop='true' symmetric='true'>∑</mo><mi>k</mi></msub><mrow><msub><mi>A</mi><mrow><mi>i</mi><mo>,</mo><mi>k</mi></mrow></msub><mo>*</mo><msub><mi>B</mi><mrow><mi>k</mi><mo>,</mo><mi>j</mi></mrow></msub></mrow></mrow></mrow></math>.</p> |
</div> | </div> |
<div id="Ch2.S2.SS3.SSSx1.p3" class="ltx_para"> | <div id='Ch2.S2.SS3.SSSx1.p3' class='ltx_para'> |
<p class="ltx_p">This definition can directly be translated into the following <span class="ltx_text ltx_font_smallcaps">SaC</span> code:</p> | <p class='ltx_p'>This definition can directly be translated into the following <span class='ltx_text ltx_font_smallcaps'>SaC</span> code:</p> |
</div> | </div> |
<figure id="LST19" class="ltx_float ltx_lstlisting ltx_role_listing"> | <figure id='LST19' class='ltx_float ltx_lstlisting ltx_role_listing'> |
<figcaption class="ltx_caption"><span class="ltx_tag ltx_tag_float">Listing 19: </span>Matrix Product</figcaption> | <figcaption class='ltx_caption'><span class='ltx_tag ltx_tag_float'>Listing 19: </span>Matrix Product</figcaption> |
<div class="ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing"> | <div class='ltx_listing ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_listing'> |
<div class="ltx_listing_data"><a href="data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgaWQgPSBbWzFk%0ALCAwZCwgMGRdLCBbMGQsIDFkLCAwZF0sIFswZCwgMGQsIDFkXV07CgogIHZlY3QgPSBbMWQsIDJk%0ALCAzZCwgNGRdOwogIG1hdCA9IFt2ZWN0LCB2ZWN0KzRkLCB2ZWN0KzhkXTsKICBwcmludChtYXQp%0AOwoKICByZXMgPSB7W2ksal0gLT4gc3VtKGlkW1tpLC5dXSAqIG1hdFtbLixqXV0pfTsKICBwcmlu%0AdChyZXMpOwoKICByZXR1cm4gMDsKfQ==%0A">⬇</a></div> | <div class='ltx_listing_data'><a href='data:text/plain;base64,dXNlIFN0ZElPOiBhbGw7CnVzZSBBcnJheTogYWxsOwoKaW50IG1haW4oKQp7CiAgaWQgPSBbWzFk%0ALCAwZCwgMGRdLCBbMGQsIDFkLCAwZF0sIFswZCwgMGQsIDFkXV07CgogIHZlY3QgPSBbMWQsIDJk%0ALCAzZCwgNGRdOwogIG1hdCA9IFt2ZWN0LCB2ZWN0KzRkLCB2ZWN0KzhkXTsKICBwcmludChtYXQp%0AOwoKICByZXMgPSB7W2ksal0gLT4gc3VtKGlkW1tpLC5dXSAqIG1hdFtbLixqXV0pfTsKICBwcmlu%0AdChyZXMpOwoKICByZXR1cm4gMDsKfQ==%0A'>⬇</a></div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">1</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">StdIO</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>1</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>StdIO</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">2</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">use</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">Array</span>:<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">all</span>; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>2</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>use</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>Array</span>:<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>all</span>; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">3</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>3</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">4</span></span><span class="ltx_text ltx_lst_keyword ltx_font_bold">int</span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">main</span>() | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>4</span></span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>int</span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>main</span>() |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">5</span></span>{ | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>5</span></span>{ |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">6</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">id</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[[1<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>0<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>0<span class="ltx_text ltx_lst_identifier">d</span>],<span class="ltx_text ltx_lst_space"> </span>[0<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>1<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>0<span class="ltx_text ltx_lst_identifier">d</span>],<span class="ltx_text ltx_lst_space"> </span>[0<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>0<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>1<span class="ltx_text ltx_lst_identifier">d</span>]]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>6</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>id</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[[1<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>0<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>0<span class='ltx_text ltx_lst_identifier'>d</span>],<span class='ltx_text ltx_lst_space'> </span>[0<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>1<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>0<span class='ltx_text ltx_lst_identifier'>d</span>],<span class='ltx_text ltx_lst_space'> </span>[0<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>0<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>1<span class='ltx_text ltx_lst_identifier'>d</span>]]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">7</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>7</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">8</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[1<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>2<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>3<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span>4<span class="ltx_text ltx_lst_identifier">d</span>]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>8</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[1<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>2<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>3<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span>4<span class='ltx_text ltx_lst_identifier'>d</span>]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">9</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>[<span class="ltx_text ltx_lst_identifier">vect</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+4<span class="ltx_text ltx_lst_identifier">d</span>,<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">vect</span>+8<span class="ltx_text ltx_lst_identifier">d</span>]; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>9</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>[<span class='ltx_text ltx_lst_identifier'>vect</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+4<span class='ltx_text ltx_lst_identifier'>d</span>,<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>vect</span>+8<span class='ltx_text ltx_lst_identifier'>d</span>]; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">10</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">mat</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>10</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>mat</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">11</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>11</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">12</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">res</span><span class="ltx_text ltx_lst_space"> </span>=<span class="ltx_text ltx_lst_space"> </span>{[<span class="ltx_text ltx_lst_identifier">i</span>,j]<span class="ltx_text ltx_lst_space"> </span>-><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">sum</span>(<span class="ltx_text ltx_lst_identifier">id</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,.]]<span class="ltx_text ltx_lst_space"> </span>*<span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span>[[.,j]])}; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>12</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>res</span><span class='ltx_text ltx_lst_space'> </span>=<span class='ltx_text ltx_lst_space'> </span>{[<span class='ltx_text ltx_lst_identifier'>i</span>,j]<span class='ltx_text ltx_lst_space'> </span>-><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>sum</span>(<span class='ltx_text ltx_lst_identifier'>id</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,.]]<span class='ltx_text ltx_lst_space'> </span>*<span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span>[[.,j]])}; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">13</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">print</span>(<span class="ltx_text ltx_lst_identifier">res</span>); | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>13</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>print</span>(<span class='ltx_text ltx_lst_identifier'>res</span>); |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">14</span></span> | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>14</span></span> |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">15</span></span><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_keyword ltx_font_bold">return</span><span class="ltx_text ltx_lst_space"> </span>0; | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>15</span></span><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_keyword ltx_font_bold'>return</span><span class='ltx_text ltx_lst_space'> </span>0; |
</div> | </div> |
<div class="ltx_listingline"> | <div class='ltx_listingline'> |
<span class="ltx_tag ltx_tag_listing"><span class="ltx_text" style="color:#BFBFBF;">16</span></span>} | <span class='ltx_tag ltx_tag_listing'><span class='ltx_text' style='color:#BFBFBF;'>16</span></span>} |
</div> | </div> |
</div> | </div> |
</figure> | </figure> |
<div id="Ch2.S2.SS3.SSSx1.p4" class="ltx_para"> | <div id='Ch2.S2.SS3.SSSx1.p4' class='ltx_para'> |
<p class="ltx_p">After defining two matrices <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">id</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span> in | <p class='ltx_p'>After defining two matrices <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>id</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span> in |
lines6 and 8, respectively, | lines6 and 8, respectively, |
the matrix product <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">id</span><span class="ltx_text ltx_lst_space"> </span><math id="Ch2.S2.SS3.SSSx1.p4.m1" class="ltx_Math" alttext="\odot" display="inline"><mo>⊙</mo></math><span class="ltx_text ltx_lst_space"> </span><span class="ltx_text ltx_lst_identifier">mat</span></span> is specified in line 12. | the matrix product <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>id</span><span class='ltx_text ltx_lst_space'> </span><math id='Ch2.S2.SS3.SSSx1.p4.m1' class='ltx_Math' alttext='\odot' display='inline'><mo>⊙</mo></math><span class='ltx_text ltx_lst_space'> </span><span class='ltx_text ltx_lst_identifier'>mat</span></span> is specified in line 12. |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">id</span>[[<span class="ltx_text ltx_lst_identifier">i</span>,.]]</span> selects the <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</span>-th row of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">id</span> and | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>id</span>[[<span class='ltx_text ltx_lst_identifier'>i</span>,.]]</span> selects the <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</span>-th row of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>id</span> and |
<span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting"><span class="ltx_text ltx_lst_identifier">mat</span>[[.,j]]</span> refers to the <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">j</span>-th column of <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span>. | <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'><span class='ltx_text ltx_lst_identifier'>mat</span>[[.,j]]</span> refers to the <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>j</span>-th column of <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span>. |
The index ranges for <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">i</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">j</span> are deduced from the accesses | The index ranges for <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>i</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>j</span> are deduced from the accesses |
into <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">id</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">mat</span>, respectively. | into <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>id</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>mat</span>, respectively. |
A variable <math id="Ch2.S2.SS3.SSSx1.p4.m2" class="ltx_Math" alttext="k" display="inline"><mi>k</mi></math> as used in the mathematical specification is not required | A variable <math id='Ch2.S2.SS3.SSSx1.p4.m2' class='ltx_Math' alttext='k' display='inline'><mi>k</mi></math> as used in the mathematical specification is not required |
as we can make use of the array operations <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting">*</span> and <span class="ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier">sum</span>.</p> | as we can make use of the array operations <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting'>*</span> and <span class='ltx_text ltx_lst_language_SaC ltx_lst_numbers_left ltx_lstlisting ltx_lst_identifier'>sum</span>.</p> |
</div> | </div> |
</section> | </section> |
<section id="Ch2.S2.SS3.SSSx2" class="ltx_subsubsection"> | <section id='Ch2.S2.SS3.SSSx2' class='ltx_subsubsection'> |
<h6 class="ltx_title ltx_title_subsubsection">Relaxation</h6> | <h6 class='ltx_title ltx_title_subsubsection'>Relaxation</h6> |
| |
<div id="Ch2.S2.SS3.SSSx2.p1" class="ltx_para"> | <div id='Ch2.S2.SS3.SSSx2.p1' class='ltx_para'> |
<p class="ltx_p">Numerical approximations to the solution of partial differential equations | <p class='ltx_p'>Numerical approximations to the solution of partial differential equations |
are often made by applying so-called <span class="ltx_text ltx_font_italic">relaxation methods</span>. | are often made by applying so-called <span class='ltx_text ltx_font_italic'>relaxation methods</span>. |
These require large arrays to be iteratively modified by so-called | These require large arrays to be iteratively modified by so-called |
<span class="ltx_text ltx_font_italic">stencil operations</span> until a certain convergence criterion is met. | <span class='ltx_text ltx_font_italic'>stencil operations</span> until a certain convergence criterion is met. |
Fig. <a href="#Ch2.F1" title="Figure 2.1 ‣ Relaxation ‣ 2.2.3 Putting it all Together ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC" class="ltx_ref"><span class="ltx_text ltx_ref_tag">2.1</span></a> illustrates such a stencil operation.</p> | Fig. <a href='#Ch2.F1' title='Figure 2.1 ‣ Relaxation ‣ 2.2.3 Putting it all Together ‣ 2.2 Lesson 2: Shape-Invariant Programming ‣ Chapter 2 Array Programming Basics ‣ Part I Trails Covering the Basics of SaC' class='ltx_ref'><span class='ltx_text ltx_ref_tag'>2.1</span></a> illustrates such a stencil operation.</p> |
</div> | </div> |
<figure id="Ch2.F1" class="ltx_figure"><img src="x1.png" id="Ch2.F1.g1" class="ltx_graphics ltx_centering" width="209" height="130" alt=""> | <figure id='Ch2.F1' class='ltx_figure'><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANEAAACCEAYAAACIsPH1AAAABGdBTUEAAYagMeiWXwAAAAZiS0dE////////CVj33AAAAAlwSFlzAAAAWgAAAFoAcCO4fQAAAAd0SU1FB+EDGBMiBpNwmRsAADatSURBVHja7Z1nQFTH14efXTqCoFhAEBQbVuyxx5aoscRYsLfYosYajV2jMcZeEntsMRp7jTVRY8feGxYEUSmCgnRYdt4Pd/gn+qZY2AXjPF9+sOXes+femXNn7txzLFAoFArFfxDLepo2nq9pmRyaFkjS9PZp+cE5ylcKhUKhyECy39a071JNnefKN3SaePho2uE35SuFQqFQZOQI6BtNe43U1KrzP3++7HFNy61TvlMoFApFBtCmkBwB/fSSXzioSadPle8UCoVC8QYUP6Bp9Zuv9/2avprmX698qVAoFIpXQD9M067ynhAFX287lg81bRmTab9EHUyFQqF4G6ntpOnBVPnCvdfbjsFdhoNFKhApFAqF4iWwDtPU9ZKm90tkzHZjQzXNXkr5WKFQKBT/QOPvNM11LmO3mydC01orzf2LLNVBVSgUircBGzkV5ySXaUeGZ+z2I+UUX+485v5lampOoVAo3grqfKnpb3NMs32jvFekO6wCkUKhUCj+hIUMDM4nNH3czsQ7dFM+VygUCsWfqF5e04LXzLO/xjIQZeujfK9QKBTvNLqFmnZqZ979+sgRWAmzTdGpqTmFQqHIkhSTmRKutTbvfkP2aer1vgpECoVC8U5TvrKmF340736Tqmpqs9pce1TLtxUKhSJLkTOvpk+KaSq2m3f/aZNkeCitRkQKhULxTvK+HCAcCcskA05Jza0CkUKhULxTWBg0tZbJRxOaZLJBN821IxWIFAqFIktQRtYTuiiyhj1Gs+Wcs1AHX6FQKLICEbM1jbSSL1zNXHt8HDS9Ey0DU4I6RgqFQqEwI9VvaZp3n6n3pKbmFAqFQvEXPOmqqUsR5QuFQqFQZAI5j2hax1qNiBQKhUKRCcT9qmm2hyoQKRT/GSzrZSuRrUS2Ejm9M8uCvHnz5s2bN+f7Vuus1lmtyzUwc/3htlNT+6eZZYHrHtc9rntyfiWPT2Bm2WFnb2dvZ5+nZ9Y6X40/yTARrQKRQvGfweFZ/PX46/HXfSMz1448MoWLW0jm2lHgY02zf5JZFiSnJqcmp5Y7Le1YlVl2JCYkJiQmVA/MWudr2kFNLUx+nqhApFAoFIq/QJSQYeK2CkQKxX+CyWMnj3VrAVWWVlnqVgiEEEJn9tVIibVqfFjjQ9eexuRq/tX83Z5qdjDHjJ2bEELnCHUn1p3oegg+G/LZELdR0o6WZrYjLtXRd63vWrc14Dfab3SexpnQ2QshLL6Aipsqbsp3AfzX+K/J0zaLnLTJ0sb9qv0qFG81QfeD7n8dBwmHEw4nT9dZB8UGxRpmQHTb6LZbBcS3j29vM8/EHW4aBJ8KPrVwq65f7LnYcylN6B4TFxOX+inEWsRaLD8KoYtDF1u2MZ0d05dNX2aVBBFxEXE/X2F2dPfo7qkG2iZ2TeyavAuifKN8Z9zU7NV/ZDo7dhXfVdxhLEQ8jni8K0a/JbhmcE3DJXjm/cw7YS/Ebo7dPMZaBsYvTWfH4ZuHb+ZMhOh+0f2OdtNZ3fK55ZO2BgwGgyE2AcJswmz6bMwa53DL3qodKxRvJWEpYSm+ZcGYz5jP6A3inDgnBIgYESMEiJ6ipxAQ2CmwU4/BprPjbMzZmPoDwPjA+MB4CkS4CBcCRIAIEAKMccY4sRyu6q/qmz0xnR0xdjF27RzAmGhMFDP/ZMcdcUcIMB42Hjb6wKnLpy5XN+FxCQwMDBwwHsREMVEIEHEiTggQv4hfhIDUb1O/TdkMh/od6uez0HR2xOvj9V+HgOgoOgoBIkWkCAHigDggBKTcSbkTdxLW9lnbx831vx6IVBkIheKNKVRH0zJJf7z2Rfcvupe9AYv2LNqjCwaH0g5aUn0dOgDccAPY4b/Dv44cAUSdzHjb5myfs73WVpinm6fTzQWnjk4dAchDHgDdId0husH6kPUhH60E3HG3qJrxdkxLmpb0YUMYW3BsQYaATahN6J/tMNYx1tHdgKU3lt5oJlcV5jFBB/zT1Z+uvl8aRtQfUR/AOpt1NgCa0AQgYVTCKKsWMHXz1M0tcwHzmX/dBP7YVmFbhWoloL19e3ueAVZoiX2qUx0gyTfJ174BzE6cndhKjswe7Hx+G5c/1/RuB9UGFQrFXzC+4/iOjhshaW3S2uBDIDqLzkKA6Cq6CgHGgcaBSS0hcFvgtjJHTWfH8SrHq+TbDcnTk6c/7gtihBghBIhxYpwQkHAk4cjTjyBoQ9CGgu1NZ8e538795mMLKV4pXs82/skfH4mPhIDUL1K/eDgZAkYEjMjTyHR2XP/q+ldVQsAQZ4hL+uYPP4hBYpAQ8Gz1s9U3+8OjBY8WOESbzo67m+5ualQPDFUMVQx7QHwmPhMCRHVRXQhIqplU83RJuFTiUgnrjpl7LrdordqzQvFWE+4R7uFVAm58f+P7xfPhwMEDB3fdh3P+5/yrzJP3IjxNb8ft6ben+xy0anra97Tvz/N1/Q5MOjBpw204Pfj04DKfSzucTW/HnYg7EeVvwuqnq59uGwgXa16sucIJrk64OqFwmun3L4QQ9IDgQsGFarpYdjzQ4UCHvUXh7o67OxZYwK4mu5rktzdD596iRQtOwL2i94o2uKBru89/n//v4fD4zOMzU69BSK6QXLmySBbuVuVVO1Yo/jM4V9K0TvbMskB7oNVnhPZAa+kWmeuPqjL7v2vtzLIgx44cO3LsqCenRnN+lbn++KRe1jxvP0kvVW6ySrHqHpFCoVAo/oG4rZpmz6Hpswzfg3qOSKFQKBT/QMJeTbM5m2oPKhApFAqF4h9IHKKpzR0ViBQKhUKRGSOiY5ramSzjgwpECoVCofinEVEzTe0rq0CkUCgUikwgST5Qa2eych0qECkUCoXiH4ix09TRPZMDUZGa6mC81SyWel25QqFQvBpCZkW3jM6kQJRniaY9pquD8TbTrYam5d5XvlAoFK+GsYL8o2EmBaKq8gr6hKs6GG8zl2TlxxrVlS8UCsUrMlITXe3MCkTxmvo7qGPxNnOruKZFKypfmBshhGADfD/7+9lFqkOH0R1GF/WD0sVLF7d2M68d+grxeTsd7HSw8Mq0Vt1Cu4X6hID/Wv+1FmYskf15M7BcyZMO/jzxmciFhVe4UCoQPDxAb8ZCgacbnm5o3SZl74eVP6xcuCx8d+a7M0U3mb9gYa8VvVbYGqBRRKMI72Fw7dS1U0VDstY5bHwgz6GkTDJguUxCqFOLGt5ufDT5Qda9sdilXGIukgYmDfyuHCQ4Jjga6kPY6rDVohEkTEyYeHQvHHE94potxsQB6BCELg9dvupnnWVieGJ42goaJFolWhm/hdAWoS12GOGI9xFvGxPWnYlNBfu68Owx7IumfEpbyhv98Uxth2faMoibDKsqw65jYHHDdHZc2H9hv2MSRD2Oeny4iG5aeJ3wOqIcJNZMrGnIDoFJgUlzssuANMV0doT2DO2Zxx2S2ye3vzBYZ3GzxM0SYgSk2qfap9hCbMHYguPaZ41z2ELWqWqew8w7ttYqY7D4DdKxn8t1Lleug7Dfa79X+xJwu9/tfk2+lFlnL5njChD0SXC3C7wfBNHeMMtDe93i1v///J1J0LYPHJoOnU7Aky5Q3QPuJ8OXTnA0Foa6QbAR+kfLKzgT5Opr0aJFC4v8EDggcECzUPh9ye9LOhSCfTv37XSyebNtj5f3/LxUIDI5Tz2fepY9AUY3o5vxfRAPxcPnCrF1Ep2EgCjvKO9Bvqaz41rwteD6cSAai8bCBkSEiBACRIJIEALEt+JbIeB20dtFu/bSvmN/KuP13ALoOQbSRoG4DeKp1hbFTU2N2UE4w6/DoaHOdHZcPH7x+NAcYOxi7CIEiGSRLMQfx8cw1zA3rTQcbnm4ZdUjprPjUa5HuaZ2ANFetBcCRKJIFALELrFLCEgZlTIqqSusKL2idPGWf70dSzOV8NYXloHIZBVj/6YjLeWk6dXXuFLr1KlTJ+sdkL9S/kr7skPIvpB9vfeA5S3LW8N2waKWi1rm6gRbtmzZstKEztvnAlUmQ+VHMP4BONlAgXbae186/f/PO66HriMhR14YuwPs58K2mvDgPgzICT/3Av84mB4At2LgZgH4pRc4PICgBRln96SPJn00ajDocutyZ48Ay4aWDU/2gfIzy89cvVO7Uvt4L+h0Op3R9tW2fb65puVHaRqs4sUbkjMgZ0DOgIIdU+1S7VLtKnZPf93QocesHrNKNEtqvtR6qbXuuPjC2c1Zm4hLL4xXkIJg3XTdhXUXqhezme943/H+wzkZbV9q31lHZx2tsj150FT9VD1Jor5Lbpfcz30khBDQTd7svNm5oq0YBfBobcZ7ancklCvMkWKHOELhhvuPjKMWhPV3/Q3g4rQy7RjGU4psu0aR9ybTC+hlzHg71u/fvH+z7yLO+TT1aQpMs7G2sQYgBzmAIwmlE0rrL1Nr3qB5g2o4y76hW0aboat3oOiBoiVOiQMdC3fUunlbtNZcn/rA0WTvZG/rCGr+fOznYzVl/5L/hfPjprx3c9/UF/VXpJq7LlHfZZpW3PHq3/W/63+3QSsQX4gvxEit43TbCilHUo7M+B6SRJK4FK1NSeh7mP63nPaEOXu0q67AYZpahv/x/kEgn5+WUda/O5yuBA7NITk/BCdCahG4dgD8V0CXcxCRCluzw7naYFs/4+zsNa3XNLv5ENc6rvXDAprfBp+EmKSYpIqjwRhkDErrBSE/hvzoa/V6+/D4WtOvK6kQYmr8R/iPsMsFcSviVlyd8ccIKL0QW0qDlAax2+GQ9SHr4iacgrkddzsup4Dk/cn7g7aw1NDE0EQISqaGpoYKAckrk1dGnIazDc829FhqwpFZFHhNg+RYiPD1G7JuNQhRNeF4Ya1NxodBwD44ewacd5vOjqhiUcVKV4AU/xT/mMN/Kow3UowUAuK3xG+51BJ2R++Otj9rOjvunLtzrkZ3MAwyDEo89yc7RovRQkDUr1G/Hp6qVZS1jM3cc1l3UVM/LzPveIG8KWWz7dW/G2cRZzG0gdaRCqGpqwxIUy5BUkhSSHJjuF3vdj3bPJkfiG73hZ73IS4Nxv+pEFVqZ6i3BhK84Ok1SA6AlHIQMwb6zNG2w28ZZ2dYq7BWnrsgrXNa5zTpr0HfaVp23x/+DLsXdq/dyNccAMvAv/iWChTmYsXFFRdz+8PlUpdLTb6l+3bl2ZVn192Bc47nHH2LycUMeU1vx03fm76e862L76m0p9L8I7rlm/pt6rf0B7iuv64vWtp8/jhcHQr7DX/0ZS9Y/7TJw7nfwEJ3eNgSXLebz44Hfg/8yna37r3h6oar65vDxcMXD0+uC2f8zvjlLWH6/acX6Lvw3oX3qkTphi4suLDg9ikQnBqcOtIXFhkWGZx3ZJGTWK6a/iTNzPtdKQtW0fXVvxtfIb7C0Bt/H4iSaybXTP4e7ta8W9PWO/MDUXg+2JcdbuWAUmXkPaSdkHIdNnnDnS7Qqx5EB8KvE8CwE5J/g90ToPiwjLMz4kTECS8gbXna8rSDfx+IInJG5Gx3/g0vNK5qahuhAoU5UYXx0jnbE8AvdtSPANWGZ5YdqjBe1rDvhdVwDn6axjxKj0ivceX16c1PLx8DRjCCsXJo9wE8bv+4vc0ViLONs72xDiYXnVw0pVTmOfWAG+RrC7aXIHsrSHCHG9NhSxlwtwFsoektKLQSdvSEgEowoCMwFiyWg/WH4Do/4+yZOXLmyIgSkLQzaWeoHCnq6sMpy1OWNlcgbWPaxrRLcKb1mdZXLd5sX4EyVUehgyo4KBSKl5xRyWayLT//r69B00tv0NEd0R/R/34VvCO8I86uhONLjy/17AflNpbb6J4IYVFhUbMewjKnZU7G46Yc+oLXxxDZA8o0AYMjuOSDSz2g4i7I/xOUvQ8WzrD3KpS9CmkFYFMohA6H6AA4aAUphaHZICi4CWKPQ6wXHPaGog3g1ILXHzm+yNTDUw8nXoe+RfsWnT8WxE1x0/MYWA+0HhjiA5H9I/vv3gZLxy8df63Am+3rosyw4CuviK+pNqZQKP6FtPR74hk+ZfhCICo7WtNTb3Aze3CfwX1S54L9evv1jdqD+8/uP9ftAtHFoov90ACsKllV2m9nHsfF74JcS6HjSkDeiC2WA8TvsCEO4g9D4o8Q1v+P77Ryg9SpcKsPfLwLbiSDz1SwugZiLOy+DY2OwLxISHmQ8TY/qf2k9rQ+IGqKmo3ywaM1j9bY1IXzruddO9yArX239jWOebN9XJOBs076cf5KNTKFQvEvF/cmu4f3QiAqeUbTZYPkCwNff9O92/RuE/mz9veG9Bd/NZ/TdDqIlCM8Ov3FB5ZC6PK//37RhZByFVgIl7uYz+5yS8otSftQ+3snQAMaMD9j9/FYzonn/lE1LoVCkdm8cI/ITt40TLqqXPNfxiAzLQhZX8RSZeVWmIVNFgDVGybWByj6Q6XOAFUPL54B4HNAeejdRI6IdEdlB+UpX/dSrnkXCO2rqatR0wfKJQqTUmsjQEwZ+1CA0T6p4QDJJW+PBPjRT3nonR4RedTR9FE75ZJ3icBcmhZepHyhMAcR7wMEnrddBxBvadMY4OG2SikATxoqD2VlLExdKrywfJDzVgfl7HeJW2U1LXJY+UJhDkq5ACTsT74CcKM0pQAuOOt0AMY1ykNZmbTTJg5E3jKlzz1VAO+dIkhe4Xg6Kl8ozElKc4Bz4bHvAZxtrjzybiMDUb5imj448vqb2tYNCvpC0mCovfjvP3dpFrTfAxPmg8dFiPgV6rrBms7gNw2i4qH9LJgeATYzMuqHCgGgW3y+IECf4LGOAO6FX3jf+8gogP6fLvoIwHFTdCpAM/FTa4D20x87A3z0c4sWALoMyDa43wYcQuBBbmj+u8z8UPT/fy6wGpRuA+vzQMNj2so3781wzAPafA5XykP3YXDlCXj+8HL7jgvQNNs61RQUZg1EVQHO5w3/DuBctPKIApgn7xXYvkJZAyHAJgJObAW/NEjKB9FTtdcXzvz/nx+TB6yXQtRpuFYWoidALwd46g/HLSH4IejLwyMv2DwRQtNgfIblfLq2DKBzmlgHYHTpPxug0v9KZ+8fAuDzQZwXwP6qcWUAZntG+gLMu3F1MYBVfERTgFvugTEATd9gznR3d6jqAzGP4WBZzW+hX2pq+xdlAcKmwMISEGUFvZpC/Eh42AeuFNSm1s5sh9bXIeY7uLJQpir6l7Ttelm5dfEp1QZMhRBCWPwCq5JWJTW8AN02d9s8/DDEzo6d7TDKfHbs6AFWT+xmfLXVbkbnz/Q9xhXR9+jdAzYVAtv15rIioTGAfb7TJQF66s7UBmhVMKE2gLUZM61c2QKOOe2udS5ud22EL8yrDY2nwZzdYLHQfHYkjk0cm7MWNKndpPbErRBQLaBa1QBZDykpa53LJk9BtEjWu+Cb19/GXQF3v/v7QHR2AHzQB2I+hxW3IGoTTN0FSRshNj+EFYP3YuHOAVi7DGK2wuc/vekv2+MEUNoupBDAxALayEeIFwNR0EKAEV9HjgL4/MqzLQAHJsb3B7gpboUCePd/0BfgUvPIhgC1dr657/1nwzej/j4QTVkCdo0hsiaczwuX/aD2T2CcCcal8Lg6jDfA/hBoXRzibsOhArIe06cvZ8OSUShMEIB08yCsRFiJNRMg5VzKOdFEp39y48kNISB2Xey6q5YQuyx2Wc67prPjuwJgVQOSv4Y9VfFL24qf+A7XNAOuQkDSD3D8J1i+HbL98O+/CkDf4KodQKkB2xwBchzRXmfi355h6wEcOuz0ADg+/tpCAHH+ShkAsWWXEWDnlcSBADZ5/2Vmo9KZAQC565yfDFCikNz/+Je4JO0AuYpBqjNcKaa78LSk7oIQkLwYjFchfh6sdoVG3mBhwgfv9/y651fP3yFxeOLwwPI6fcTGiI1CgLAQFmlpEDU9avrcaTI5aha5UDRdIEofARWS+uQNGt4aEAlAB+AvyhQULA+tF0PscNj0FCx3wvVJYJEbWoyBXJbwex9IGQK7+kN0Z1hc57WvvAIAHBzDjgPUsnStDHBQrk8e++KJ7RYVCtD0sydeAO36uTUFuJHL+guADVFenwJc9Ay5ATBzhvs9gCNXZG2ZN8A4R/ptEGD9/9//2FobOVnHwdWlEP0RHOsMKXdhdV3IaQvjukHpHXDXCWLSoIkHOAwA4/KXs8Giugocb4KFLMFu9adVp/sH7h9YoQnUbV23dft1oC+gL8AvwpgjZ46cAKxlbclUuOVwy+EzeY921syMt61SU2jYEyy6QcOp+rL4sYH+pe9emQGgz5G2AKp1rFQ6fAcMjFm8HmDPrH/Z6P2CRwA+tvHeBzBw7LMZAEFNYxoAnG+pDwI45xxyAuDshw/2AVROKrgQoFrnwvKRbToDUE53E6Dx1mMPAVoeD34M8KCDy2yA8t/oawNUiIk/AlB+aalJAG69LNMAxlTQNmbTQAak4n9nePtRx1ZDh6E3tyUFQqlPU7bbFBPl4Bola4OuJDv4jh3tG9i2rTfHtu2a606O53s6OV6cm9FHJfKq27du3w7vnZbbtrRt6YKXhdG2lW0rAEII0etZlm1qtql9stuvGbpu6Lp1Uxyv5c2bN2/Qiee38mxaeHh4eHh4/La3vQXJQJSSfuINzPhdjFsN1hOBMlA9FWzPw8Ce4GQJ7n0hdCWcPQuOa+G8G+RvCa0dIPIEDJQVCGdUe9W9xlYG6Lk8b36A8/0trwAU/t8JVe8uQH6fgzkAYvO85wuQWKNICkBIraTrAIUePsoGsLNJzlCAwgbvbwBGVwkeAXBCPhD6mwkPUY5q2pSbYQhs2g4VNoK+MaT4wuN28HAXLOgHXo2g6wFI3gc/5oAfLKHWZ9CzL6T+y/LseH8VTF4PW4OtwdbgNjHJMskyybJUwp9GIi7fuZSozP1K4yqNYwueTkYn43NfDSIIdBWPxh6NLdpQnAWofTLjLVz8E5Qbz/1iKdxnlkVxh7l4Qmm/K6cALM8btgJUmnWhGRSy0K7SfK3/dbO/AriutPoVwPGC/iCAa/b4GIACpZKSAZ7McFwL8HQiRwFyrrJLz1Zm/bza9NEuuZ0mAbjWcJgIYLkvfiBAwdE2YwEKWtj/CpCnPA0BHCOeBAF4LM9zDF7G7vcWnCsCns1sClh3BIhfli0Q4BoltUTDInUYQtczbfSFPWmjC95/1vvZtWe9n1XI8MMy9vbQ20Pz+IBvtG/0c+9kIxtgNK41rrXIZvAJWR+y3rvzsw3Prj27pn/Bjnt6cpGLXPH/lea0KH1q5ovX38ad1XBnyv+fmjsTBh+Mh5jNsOK0HIO4QPQOWNZb+39uUXlPoxjEHIfjpSAkCva2ff2JEYCt72kaXknTJ9fTp+ZSgwCOxQV1BBjxY+QRgM//F1HixgJckldYnT48cwEgR5nEIIDHVjefAkwa8ea+P+4Fkwb9/6m5b+uBXXOIrAPnC8LZdeD4GAKnwweLtBHow/LSb0chFBhUHRIeQGJ3mN4d3F6y3MAP01RIyWgaeTfytqoFsdtit50YCsZmxmYimbGpdVPrCgGJoxJHRbpB0IygGV4mXK06+xQ4GiHeCFcCGZDqwgAh8Eypi6cQkPAN3JsE4QMgd9+XnZo7tBug3rF7xwCKeoz6HMD23t9979QFgLw796wCuPd+yBhta8H9NN25EeDyk0fnARwH/N125vcEyLY7qAlAyUW7PgGo8fTlp+YOjofC9pBSFsLdWJo6lqVCgLGr9utiK8KRHhBXGWxMeE8k4JOAT8p1huTZybOj7zI2pXZKbSFAVBVVRQA8XfV01Y5R2tSc/tB/fWouvSNKn2Ca8+rfPRoPtsUhYiiE+UKMG6xrBftHgm4oRM2EJQUg5Ado/KeIfqsdjGoGiUmwcSNcSQR9LMQMhT0e8GQtDH/tm5faiWm9QFPbi5p+8G16IBp3H6B6g8iTACcKBhQC8EyfouTBKYDNu+O+BxjZJqEbgN2E2C4AgeseLQd4k+fvhACdO9zeAAuLgKE1PGkKa0eAy3dwYw7UnQ8xcbDqT+Uaft0CJeMgcSI80sOZ9ZD7QwjNBt2mQ0IqnFwCm/qC1UumalrcSwUOUxF3I+6GY3M47n3ce/B87k/7adpPC/bAseRjyeZMYHJ/GbjstnHatsXGaWIX3fXVl3XXp34Ld+uB6y5zWXHlawC3/Yf7AUwx/JYPYIT1pZoAOSeazx+PekDBLjbnF1S3Ob+oH1zsAYNi4fQ34DjPfHYE9Azo6TOJy6OLjC6yajjcS7mX0nUhxB6KPWRnl7XOZZMHolkNNHV4hbIMQoBFvLZcu4EriFHQbQQkfASdi8HDcPCtBIfHwMi2EDIbbP905ddrOFheg8eR0HoNrHeGDkchIAGaToEnM8Aiw4bEWgDKm6Jptw1dbAC881/aCjBkm7xX9L8O+UQAgFMrbVa2y/69eoCOO8/3Bag2X16B/fhmFpVpCck/Q0e5yq3bBgjfAg1mwe6z0NwTLv8O733zwi+pD/eCoNIp2PUedLWGwPbQaRDsnQAuL1mwT1deXohksdU5/1VUYbx07tYCaNvsWAGAKo0yyw5VGC9L2TdM3oMpcll1Fu8SdiGafj9Y+UIFInMSHgYw7fLDRgD93FQgercDkXyg9eEnmub/VXUW7xL2cpnss+HKFwqzXgJNAahw3nE4QHlVjuQdR66au6stKKWM7JBUBel3Aw85FRnhqnyhMAe/2APYFLM7DVCqReIFAJdacmrcR8s5J24qT2VFLEw2cpUjotsyVU0R9WDjO0WR3zW9Fa18oTAHJTwBCvxgKAaQI0XXGKBgje2JAM5dlIeyMsY8Jg5ETyZomjN9GY+Ncvo7EYjekxcitsoXCnMQ+SGAe84HuwDmZbveFWDhZYuVAPlGKA9lZcQlEweidHQyIGV0aWpF1sQjRdOHHsoXCnNQeS7A78R8DHDSsH0PwI6qTfoAXL+mPPRu8kIgipY3rzNiiHxh3IVxZRbAMctjln3d4M7YO2OHFIV+n/X7zLqc+X5i+ClwegK3vtKWjBv3Q/2/SNkxpTpYfgdXGsLSHuD/AXg9hJhB8KUR1qyELjvhyUoY3xD6+YDdz6az+2Stk7XylYGfZv80u5jfH7nLMgJduBz4yuzbiUNVU1CYA3kPqNTLvq54JwPRRXdNy77BMr1RNUbVyL4BvD28PfY0gntz7s05FAiWLSxb+BaEKTOnzBxhZfqfNmIh5PaE+I+hYxQUOgQLH4GuHnj9xQigRlGoeBw8jeA8AUp1hmlbIWk1uCdC+y7woysk/AYtJ8A3paClCVIiHbc9bttoFeQrma/k+JlQvmT5kk2S4cEPD34YuV0mQaz2ZvvIKW86RhdWTUChULwkA0214RcC0SU5Eirb8vU36RfpF/lBTcheO3vtfEbo2K9jvycTwausV9nwC2DxvsX7XbLBxvob61ssNp3PpvSBx/ehliVsvgspFpDyD7+rWBS0fB/id8LmoyDWgfVqyFEFOhaBIBf4eAgYR0JMc4hJgLOlM87ead2mdbMYDqVqlKoxpQXkupDrwt2FEN8pvtOJbuA+yX3S6BWQsCJhRX6LN9tX4SBNb21XbUuhULwcVmPMFIhuyBQbxd9g+WTJuSXnFt4HFKEI3s+/Z/wNrMdaj/VaAfWX1l9qlTfznTt9DFh+BfofoN4p0IXCr+3B7jJ8eRZSP4DHl8HrGGzdCbY2cLkk5K4JdzIwNU75/uX75y0Ntj62Pj6nwc7fzj+lNlQKqxSWaAe6YF2wvTs8uPTgUoU3HMmUl36/NE41LoVC8XKk5jZTIEqVy3mt0jMsbHj1TT71e+qX/A/lB5KuJ11P7gmXvr70tdiX+c6t0gcqxoLlLAgcCK6eEFURjP3hgzrwrBUc6AVPq8Li9ZDrMfT5Hh6Mh/azM86O2itrr7TpDtbFrItZ3/n7z3ln887m1ODN9lVE5oG+WVE1LlPzoNGDRjbn4Le9v+1tFs606bun7270DBZOXTg1Txnz2XF44uGJDlYxUfPPzD/TyDOt2w9lfyjbtDv8Xu33as5jzWhHCOR8sK9E1x1Q6+Ct42NcoP5QWH0Dsj0ynx3+A/0H5lmcuPHLhl82/PAjOPj1wa+brYe19dbWszXjA95blm9Z7mFgwsiwkWF1a8O9Pvf6NL8B52POx1gefccbz+xbmuZ4jY7q9PTT09+bCaKMKGNcCw8jH0Z6VIegfkH9vtdBZFBk0KGVMKTXkF66Kqb/LR4e4LoXEutB4jYtV1v3zX+8/7gaTN8Fj76Ddl//KaDGw8182ufb2cPSg2A1G+Ks4f5vcGc9TPw+4+xcNHzR8BwtIGl70vboU9q9oEHfQUyXmC7l24CYJ+aJH+BA4wONa41+vX3o5FTcssooTIwQQuh/g+RhycP2xoBxmXGZiGa44RfDL0KAoYKhwn0DXPG+4u02xXR2xG+L32Z7C55ueLrBvw2IMWKMECDGiXFCwNOGTxteGws3uYlzqunsCAiD3D9Bwm24dd9vyLrZIETVhGMGrY0lNYYTwXA1HOw7ms6OkFwhudxrQNyouFFBNZlu2GvYKwQYTxhPCAHhPcJ77LoFYSfDTlr5mc6OiM4RnYt9CkZfo2/EWYanRqRGCAHGYGOwGADxNvE2q0/IRUqHMvdc1skKvm1M9kDr35QGP3NF0wqyVPf+sy+/yUpDKw09vQZCE0ITNnwAwROCJ5SfBwW7FOyS/y7cy34v+1fvwawls5aIrqbsCMAqCi6Ph/LFwSoZrKZA6F4oFQSnx0IOd9CPgnoPQT8Avm0jvzwWYtrBjvEgakE1W2jsAWffg7QeEDsOnNrDRlnQjP5vbu9nUz+b+nQLfNzp40572kBK7ZTaTm3h+JLjS3IHQMMVDVfc8oFjnsc8z9x5vX3klCXhn7ROv2pQAePN8FziucRzic2C5LHJY5PHOvyvjMqTk/tW7FtROW/qznoj6o1ocJz+OmedM42YaqG30OYh9rAnv4U+2aqIVZH+W3N75p2Sd8rMDM+2HLVgd+TuyEZRhsTmu5rvqjKZjmyQ8xyWWut3Hu88vsRENhxMPZjavzN+HODAxhMZ76mTp6HtYhp4edCgSMeU0taN2AcGGyttxWZJq6GUrOpJ/l15yN+hHHuBvUf7ZrgZDQ8dOHSg1ypC2q5tu9ZrIcMsGlho8wuJJAINs+fJnuej2eydopuiayULRl4YlOF2TLq58ubKkRMZU7Nrza65KzDVMrelNvF1l7vMpaH+hv5G25ns/fTKp1fWNNW+dO+F4xIun/t86m7i07yZnM1Kr5i9M6N38DeB6NRDTdt2loFo1StET51OJ85DlY+rfNypPvRy7+VeoS5YxlrGDv4AKuesnPNeK/N0E1blocwECJRXWKWuQnpQP9IHsodDRBUYZgmNl8CTToAsl+y1HUY4wZ3Z4LsTTs8A9/1gNx1qfQotFkCUY8bb/Ljj444DbkC2qtmq9h0O3j7ePqX7QuChwENtu8D4J+OfJAa+3rZLy7pDVyxQZAgxp2JOxZzKWdZQwlDCUKL4lvTX9aWX5l+av0AdnlY7W+0s8+jvWMVRG/ |