Skip to main content Accessibility help
×
Hostname: page-component-7479d7b7d-t6hkb Total loading time: 0 Render date: 2024-07-11T13:18:15.775Z Has data issue: false hasContentIssue false

2 - Loops: incrementalize

Published online by Cambridge University Press:  05 June 2013

Yanhong Annie Liu
Affiliation:
Stony Brook University, State University of New York
Get access

Summary

We first look at computational problems programmed using loops over numbers and arrays. A loop is a command for repeating a sequence of operations. A number is an integer or a real number with an internal representation in a computer. An array is an arrangement of computer memory elements in one or more dimensions. Problems involving arithmetic on numbers were the first problems for which computing devices were built. Problems involving operations on arrays were at the center of many subsequent larger computer applications. Because nontrivial computations involve performing operations iteratively, loops are a most commonly used, most important construct in programming solutions to problems.

Clear and straightforward problem solutions tend to have expensive computations in loops, where the values that these computations depend on are updated slightly in each iteration. To improve efficiency, the results of these computations can be stored and incrementally maintained with respect to updates to the values that they depend on. The transformation of programs to achieve this is called incrementalization.

We will use a small example and several variations to explain the basic ideas of incrementalization. We then describe two larger examples: one in hardware design, to show additional loop optimizations enabled by incrementalization, and the other in image processing, to show handling of nested loops and arrays in incrementalization. We discuss the need for higher-level languages at the end.

Type
Chapter
Information
Systematic Program Design
From Clarity to Efficiency
, pp. 22 - 52
Publisher: Cambridge University Press
Print publication year: 2013

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Loops: incrementalize
  • Yanhong Annie Liu, Stony Brook University, State University of New York
  • Book: Systematic Program Design
  • Online publication: 05 June 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139567879.003
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Loops: incrementalize
  • Yanhong Annie Liu, Stony Brook University, State University of New York
  • Book: Systematic Program Design
  • Online publication: 05 June 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139567879.003
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Loops: incrementalize
  • Yanhong Annie Liu, Stony Brook University, State University of New York
  • Book: Systematic Program Design
  • Online publication: 05 June 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139567879.003
Available formats
×