Search

Filter

  • Advanced Filters:

  • to
  • Specific Data Sources:

    All Edit

    Select All  |  Select None

Reset filters

SM_onion 5 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 New Problem: Some Diagonal Fun Let us have some fun selecting out diagonals from rank 2 and 3 arrays. It is really an exercise in using some of the lesser-used but powerful primitive APL functions. There are probably several ways to arrive at the solutions. Let’s see what we get. 1. Find the sum of the main and reverse diagonals of an arbitrary simple square numeric matrix. Only one of the common numbers is to be summed. For example with M 5 5æì25 Finally there is my rather different approach. We all noted that there were only 500 matrices since each spiral square matrix was odd. Take the integers on the diagonal and reverse diagonal and arrange them is ascending order. For a 5 by 5 matrix the values are Diagonal: 1 3 7 13 21 Reverse Diagonal: 1 5 9 17 25 Taking the differences between the adjacent integers yields Diagonal: 1 3 7 13 21 Difference: 2 4 6 8 Reverse Diagonal: 1 5 9 17 25 Difference: 4 4 8 8 The values along these diagonals can be built from the difference vectors through sum scanning. These patterns lead to the solution via the following function: [0] Z SPIRALSUM N;÷IO;D;I;R [1] äN: INTEGER SIZE OF SPIRAL MATRIX [2] äZ: SUM OF DIAG SUMS OF THE MATRIX N [3] ÷IO 1 [4] ¸(1=2|N)/L1 [5] 'N must be an odd integer' [6] ¸0 [7] L1: [8] I N-1 [9] D +\1,2õìI [10] R 2/4õì0.5õI [11] Z ý1+(+/D)++/+\1,R · SPIRALSUM 1001 669171001 SPIRALSUMþ 1,1+2õì5 1 1 25 101 261 537 The sum of the two diagonals is 117. 2. Consider a numeric rank 3 cubic array. For example, A3 4 4 4æì64. If one starts from the four corners of the first (front) plane, four diagonals can be created that penetrate the cube. Write an expression for each of these diagonals. For the above array A3, the starting numbers would be 1, 4, 13, and 16, and the four diagonal values would be: 3. Actually there many other diagonals that one could extract from a cubic array. How many unique diagonals can one derive from a cubic array? Do not count ones that wrap around. Just count the diagonals starting with corner points and points on the edges of the cube. These problems are meant to have a little APL fun. However, if any reader has a real life application needing the extraction of any such diagonals, we would like to hear of it. There you have a summary of the various submissions. It looks like this was a problem with which several had fun. We always welcome further comments and solutions. December 2007, Volume 35, Number 4

Page 1 of 1

Page 1 of 1

Toggle back to continuous viewing mode

/lp/association-for-computing-machinery/new-problem-some-diagonal-fun-70gTisFND3
Welcome to DeepDyve! Rent Premier Research Articles and Save Up to 90%

Learn more

Free Article

Bookmark

New problem: some diagonal fun

Polivka, Ray
ACM SIGAPL APL Quote Quad , Volume 35 (4)
Association for Computing MachineryDec 1, 2007

More Info

More Like This Article

View All dataSource[]=actageo&dataSource[]=aspet&dataSource[]=aaos&dataSource[]=aacc&dataSource[]=aacr&dataSource[]=aea&dataSource[]=aip&dataSource[]=ajnr&dataSource[]=ams&dataSource[]=aps_physical&dataSource[]=appi_book&dataSource[]=appi_journal&dataSource[]=apha&dataSource[]=asip&dataSource[]=asm&dataSource[]=asn&dataSource[]=aspb&dataSource[]=avs&dataSource[]=annual_reviews&dataSource[]=arxiv&dataSource[]=acm&dataSource[]=berghahn&dataSource[]=cabi&dataSource[]=clinical_trials&dataSource[]=dailymed&dataSource[]=degruyter&dataSource[]=du_press&dataSource[]=esa&dataSource[]=eu_press&dataSource[]=elsevier&dataSource[]=emerald&dataSource[]=ejtr&dataSource[]=emea&dataSource[]=epo&dataSource[]=faseb&dataSource[]=gsa&dataSource[]=health_affairs&dataSource[]=hindawi&dataSource[]=imanager&dataSource[]=imedpub&dataSource[]=informa_healthcare&dataSource[]=informs&dataSource[]=iop&dataSource[]=iucr&dataSource[]=iospress&dataSource[]=jbjs&dataSource[]=leftcoast&dataSource[]=lu_press&dataSource[]=mesharpe&dataSource[]=mary_ann_liebert&dataSource[]=medline&dataSource[]=mit_press&dataSource[]=nature&dataSource[]=oxford&dataSource[]=pier_professional&dataSource[]=pnas&dataSource[]=portlandpress&dataSource[]=psyc_articles&dataSource[]=psyc_books&dataSource[]=psyc_critiques&dataSource[]=plos_journal&dataSource[]=pubmed_central&dataSource[]=rsna&dataSource[]=rockefeller&dataSource[]=rcn&dataSource[]=ria&dataSource[]=rsc&dataSource[]=sage&dataSource[]=spie&dataSource[]=springer_journal&dataSource[]=springer&dataSource[]=taylor_francis&dataSource[]=aps&dataSource[]=the_scientist&dataSource[]=uc_press&dataSource[]=uspto_abstract&dataSource[]=wiley&dataSource[]=pct

Browse: Subject Areas | Journals | Publishers

Sign Up for a DeepDyve Account

Bookmark an Article

To bookmark an article, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK

Subscribe to Journal Email Alerts

To subscribe to email alerts, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK

Thank you for renting with DeepDyve

Your PayPal account has been charged $2.99. You now have access to the full text of this article. A rental receipt has also been sent to your email address.

Your credit card has been charged $2.99. You now have access to the full text of this article. A rental receipt has also been sent to your email address.

OK

New! You can now keep track of new articles from ACM SIGAPL APL Quote Quad on your personalized homepage! Learn more

PDF Download — Not Available

Thanks for your interest in purchasing the PDF. Your request has been noted and we will work with our publisher partner to discuss enabling this feature.

In the meantime, you can get the PDF by visiting the publisher site.

Thank you for purchasing with DeepDyve

Your PayPal account has been charged $.

Your credit card has been charged $.

You can now download this article. A purchase receipt has also been sent to your email address.

Download This Article or I'm done with my download

Print Page — Not Available

Thanks for your interest in printing individual pages. Your request has been noted and we will work with our publisher partner to discuss enabling this feature.

In the meantime, you can get the PDF by visiting the publisher site.

Thank you for printing with DeepDyve

Your PayPal account has been charged $0.

Your credit card has been charged $0.

You can now print this article. A purchase receipt has also been sent to your email address.

Print the Selected Pages or I'm done with my printing

Please refresh to generate a new download link

Your article download link has expired. Please refresh this page to obtain a new download link and try again.

Follow a Journal

To get new article updates from a journal on your personalized homepage, please log in first, or sign up for a DeepDyve account if you don't already have one.

OK