Access the full text.
Sign up today, get DeepDyve free for 14 days.
References for this paper are not available at this time. We will be adding them shortly, thank you for your patience.
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
ACM SIGAPL APL Quote Quad – Association for Computing Machinery
Published: Dec 1, 2007
You can share this free article with as many people as you like with the url below! We hope you enjoy this feature!
Read and print from thousands of top scholarly journals.
Already have an account? Log in
Bookmark this article. You can see your Bookmarks on your DeepDyve Library.
To save an article, log in first, or sign up for a DeepDyve account if you don’t already have one.
Copy and paste the desired citation format or use the link below to download a file formatted for EndNote
Access the full text.
Sign up today, get DeepDyve free for 14 days.
All DeepDyve websites use cookies to improve your online experience. They were placed on your computer when you launched this website. You can change your cookie settings through your browser.