Why Dyalog ’14 was a Shear Delight

rot55

Recent versions of Microsoft Windows support touch screens, which of course means that applications can respond to events originating from touches. Microsoft calls these events “gestures”.

Dyalog decided to add support for gestures to version 14.1 and so projects were planned, designs were designed, code was coded and, at Dyalog ’14 (#Dyalog14), a demonstration was demonstrated. The video of that demonstration is here

The three most interesting gestures are “pan”, “zoom” and “rotate”; I needed a good demo for the rotate gesture. I had an idea but was unsure how to implement it, so I decided to ask the team. Here’s the email I sent (any typos were included in the original email!):

“Does any have code (or an algorithm, but code ‘d be better) to rotate a matrix by an arbitrary angle. The resulting matrix may then be larger than the original but will be filled with an appropriate value.
Does the question makes sense? For the conference I want to demonstrate 14.1 support for Windows touch gestures, one of which is a “rotate” gesture, and I thought that a good demo would be to rotate a CD cover image when the gesture is detected. So I need to be able to rotate the RGB values that make up the image.”

There were a number of helpful responses, mainly about using rotation matrices, but what intrigued me was Jay Foad’s almost throw away comment: “It’s also possible to do a rotation with repeated shears”

That looked interesting, so I had a bit of a Google and found an article on rotation by shearing written by Tobin Fricke. The gist of this article is that shearing a matrix three times (first horizontally, then vertically and then again horizontally) effects a rotation. An interesting aspect of this (as compared to the rotation method) is that no information is lost. Every single pixel is moved and there is no loss of quality of the image.

I’m no mathematician, but I could read my way though enough of that to realise that it would be trivial in APL. The only “real” code needed is to figure how much to shear each line in the matrix.

Converting Fricke’s α=-tan(Θ/2) and ϐ=sin(Θ), we get (using for Θ):

a←-3○⍺÷2
b←1○⍺

and so, for a given matrix, the amounts to shift are given by:

⌊⍺×(⍳≢⍵)-0.5×≢⍵

where is either a or b, depending on which shift we are doing.

Wrapping this in an operator (where ⍺⍺ is either or ):

shear←{
(⌊⍺×(⍳≢⍵)-0.5×≢⍵)⍺⍺ ⍵
}

Our three shears of matrix , of size s, can therefore be written as:

a⌽shear b⊖shear a⌽shear(3×s)↑(-2×s)↑⍵

Note the resize and pad of the matrix before we start so that we don’t replicate the edges of the bitmap. The padding elements are zeros and display as black pixels. They have been removed from the images below for clarity.

The final rotate function is:

rotate←{
shear←{(⌊⍺×(⍳≢⍵)-0.5×≢⍵)⍺⍺ ⍵}
a←-3○⍺÷2 ⋄ b←1○⍺ ⋄ s←⍴⍵
a⌽shear b⊖shear a⌽shear(3×s)↑(-2×s)↑⍵
}

Let’s look at a 45° rotate of a bitmap called “jd”.

jd.CBits←(○.25)rotate jd.CBits

Prior to performing any shears our image is:

rot0

After the first shear it becomes:

rot1

After the second shear it is:

rot2

And after the third shear it is:

rot3

All nicely rotated.

Thursday 25 September at Dyalog ’14

This was originally posted to Catalyst PR’s Facebook page and is reproduced here to make it accessible to people who don’t have Facebook accounts.

For information on the presentations at Dyalog ’14, see http://www.dyalog.com/user-meetings/dyalog14.htm.

On Thursday 25 September we were in for an impressive presentation called School Laser System with NFC Registration and Alerts by Chris “Ziggi” Paul, Laser Learning Ltd (U.K.).

Ziggi has previously developed other applications in Dyalog APL – most notably an ePortfolio-based nursery training solution for the Childcare company (see Dyalog’s case study at http://www.dyalog.com/case-studies/childcare.htm) which won the Nursery Supplier/Innovator 2008 Award at the Nursery Management Today Awards.

Since then the company has grown substantially and have branched out into Carer’s Careers – a company that is focused on training people who work with caring for others – and now the School Laser System with Near Field Communications (NFC).

The background for the School Laser System with NFC is that the principals are now also working with a new Academy free school. The School has 728 pupils, aged 4-11, and they need to be accounted for at all times during the day. The school is located over two main sites and has an external catering hall and a swimming pool. It also provides before-school and after-school clubs and mini-bus services.

The school “LASER” system is designed as a complete communication and information system between parents and school staff; recently it has been expanded to NFC in order to provide teachers and staff with up-to-date, relevant information. Each pupil in the school is issued with an NFC wristband and tags for their bags and key items of the uniform. Staff use NFC-enabled mobile phones or NFC readers connected to PCs to log a pupil at key points, for example, on and off a bus or at the dining hall. The NFC tags let the lunch staff know what food order the parents have requested each day and can give a full itinerary of clubs and school activities. Alerts of allergies or other critical medical information is displayed when a tag is scanned.

Ziggi showed us the parents’ interface to the system, as well as that used by the staff. The security around the system is obviously very high, using encryption and secure log-in. There is no data stored on the wristbands, bag tags or uniform items. If a child has forgotten to bring their wristband, a substitute – which only works for that day – is issued.

I believe that the system has great potential. There is a market not only for other UK infant and junior schools to implement this applications, but catering firms supplying school dinners could also benefit greatly from using this application.

NOTE for readers not familiar with the requirements for UK school staff concerning reporting, tracking, tracing, accounting for, etc. all children at all times – and who may have concerns regarding “big brother” tracking of children’s movements during the time they’re at school or attending after school clubs, etc.: This system is developed for tracking children aged 4-11. The application saves the school staff an enormous amount of admin. Parents love it, and as for issues around data protection, for example, medical information, no data is stored on the items the children carry around (wristband, bag tag or uniform items). It is already common practice that children with allergies and other medical conditions have their own little poster with their picture, age, condition and actions required in case of an incident posted in the classroom and the teacher room.

This is my final post from Dyalog ’14 – see you at Dyalog ’15, which seems to be going in the direction of Italy (TBC).

Postcard from Dyalog ’14 – Thursday

This is the last day of Dyalog ’14 so this is the last of six daily postcards from Eastbourne – we hope you have enjoyed getting a flavour of things as they happened. We expect there will be more discussion to come once we’re back and rested!

Last Night’s Banquet

Yesterday culminated in the traditional banquet dinner – the highlight of the social element of the user meeting. This year it was held at The Grand Hotel Eastbourne and consisted of a Champagne reception and formal three course dinner with live music from a string trio.

During the banquet the winners of the scavenger hunt were presented with their prizes – the ducks and other “British” items we saw on Sunday’s postcard! There was also a quiz to identify Dyalog employees from a list of clues. Exquisite food and wonderful company meant an exceptionally late night (early morning!) …

Delegates arrive at The Grand Hotel

Delegates arrive at The Grand Hotel

Banquet Dinner

Banquet Dinner

Team Herring celebrate their win in the quiz

Team Herring celebrate their win in the quiz

Moris and Luana with their prizes

Moris and Luana with their prizes

Discussion Point: Read-only Component Files

In his presentation today on component files and the Dyalog File Server (DFS), Richard mentioned a perhaps little-known problem with restricting access permissions on component files for users that nominally only ever read them. Setting read-only permission at the file level – that is, imposed by the operating system – could add a level of security to the file but it is in fact the case that component file reads can occasionally require write access to the file.

For example, suppose User A is reading and writing to a journaled component file and User B is simply ⎕FREADing it. If User A is interrupted whilst updating the file (perhaps the APL session is killed or a network connection is lost) and User B is the next to read it then as part of that read the interpreter will detect the journal and complete the unfinished update – a process which requires write access. If the systems administrator who set up the file permissions for User B had only granted read-only file permission to the file then the ⎕FREAD would fail.

Richard explained that this restriction might be lifted in future and that read operations would be truly read only – even with a journal present – but there is another issue to be aware of too. Access to component files is controlled using file locks. As might be expected, exclusive access is obtained on an exclusive tie and shared access is obtained on a share tie. In addition, writes to a share tied file require exclusive access for the duration of the write so that no other client is able to read it while it is being updated. Exclusive locks are write locks and thus require write permission. Therefore, if there is no write access to the file the interpreter cannot exclusively tie it – it can only share tie it.

Where file access has to be locked down as securely as possible, the DFS is able to resolve the above issues and more besides – client access to all component files is only possible via APL, users are fully authenticated and individual rights are controlled by the access matrix.

And Also …

Some of the other things we saw and heard today:

  • Andy showed us how to close trace windows without cutting back the stack
  • Ziggi pointed out that a loss rate of one in 700 is acceptable when delivering wine but not when delivering children
  • We would like your suggestions and comments about the user meeting programme and structure, and preferred location for next year – please email us at conference@dyalog.com

Eastbourne

Eastbourne has not let us down and even the British weather (which is always unpredictable) defied the odds and rendered the ponchos and umbrellas unnecessary. The View Hotel started life as a conference centre and was purpose built for holding meetings such as ours. We have certainly found it to be an ideal venue and feedback from delegates has been overwhelmingly positive.

The View Hotel

The View Hotel

The View Hotel

The View Hotel

The picture of the pier below was carefully framed not to show the fire damaged part! The fire that destroyed part of it back in July was headline news; the pier is closed as a result but should partially reopen next week. Perhaps we will have to return when it is fully restored!

Eastbourne Pier

Eastbourne Pier

Bandstand with The View Hotel behind

Bandstand with The View Hotel behind

Signing Off

And so Dyalog ’14 has come to an end. It has been the best-attended Dyalog conference anyone can remember and reflects the growing success of Dyalog and its users. Here begins the countdown to Dyalog ’15!

Wednesday 24 September at Dyalog ’14

This was originally posted to Catalyst PR’s Facebook page and is reproduced here to make it accessible to people who don’t have Facebook accounts.

For information on the presentations at Dyalog ’14, see http://www.dyalog.com/user-meetings/dyalog14.htm.

During Dyalog ’13, Dyalog Ltd announced an agreement with Syncfusion Inc. The agreement stated that Syncfusion’s Windows Presentation Foundation (WPF) and JavaScript libraries would be bundled with Dyalog version 14.0 (see http://www.dyalog.com/news/81/420/Dyalog-Agreement-with-Syncfusion.htm).

On Wednesday the 25th it was, therefore, a pleasure to attend the presentation by Claus Madsen of Fine Analytics (Denmark), where he presented the company’s InRisk Asset Allocation Platform.

The application is written purely in Dyalog and is aimed at professional investors. Fine Analytics have taken advantage of the WPF capabilities and Syncfusion controls available with Dyalog 14.0 to build a generic asset allocation platform with special focus on the professional investor. A specially designed .NET class facilitates the separation of the administrative and analytical sections of the application and a flexible calculation engine that allows a user to define type/structure/order is an integral part of the platform. All assumptions can be controlled from the professional-looking user interface; the user interface can also be used to change/import/construct/delete/add/copy/export a portfolio as well as add new assets in asset groups.

Postcard from Dyalog ’14 – Wednesday

It’s been another busy day at Dyalog ’14; there’s lots to write about and little time to do it!

Winners of the International APL Programming Contest 2014

This year, 710 registrations were received for the annual APL Programming Contest and the two main winners – Emil Bremer Orloff, student entrant from Aarhus Universitet, and Iryna Pashenkovska, professional entrant from SimCorp and a recent Engineering Mathematics graduate of National Taras Shevchenko University of Kyiv – won invitations to Dyalog ’14 as part of their prizes where they each made presentations about their contest submissions. Look forward to the videos of their presentations which will be available shortly!

Emil Bremer Orloff

Emil Bremer Orloff

Iryna Pashenkovska

Iryna Pashenkovska

Emil Bremer Orloff

Emil Bremer Orloff

Iryna Pashenkovska

Iryna Pashenkovska

Discussion Point: Data Binding – Reloaded

John Daintree showed more aspects of Dyalog’s data binding. Did you know that you can bind to XML stored in files? Did you know that you can create DataTables to bind to an APL matrix? The cddb database sample was re-worked to allow the GUI to bind to the data in a matrix as an alternative to vectors of namespace. Syncfusion controls were used to visually explore the cddb data.

John discussed changes that might come in 14.1, including better support for bound matrices.

Discussion Point: Syncfusion Controls

Late yesterday, Brian Becker showed how to take advantage of the Syncfusion Javascript controls that are bundled with Dyalog v14.0 on all platforms. This morning, Morten Kromberg and Michael Hughes followed up with demonstrations of how easy it is to enhance applications with Syncfusion controls for Windows Presentation Foundation, which are included with the Windows editions of version 14.0.

With Dyalog (as in any Microsoft.NET language), you have the choice of instantiating and manipulating WPF objects with APL language statements, or using declarative eXtensible Application Markup language, which can either be edited by UI design experts using WYSIWYG tools, or (of course) generated from APL.

A Syncfusion RangeSliderControl

A Syncfusion RangeSliderControl

A Syncfusion “Sparkline”

A Syncfusion “Sparkline”

Code sample for the RangeSlider:


     ∇ window←RangeSliderControl values;⎕USING;r;t
[1]   ⍝ Simple Sparkline example - inspired by Dick Bowman
[2]   ⍝ More at http://www.apldapldoo.info/apl/APL/Tutorials/WPF/SyncFusion/overview.html
[3]   ⍝ values: Numeric vector of values
[4]
[5]    :Section xaml
[6]        xaml←ScriptFollows ⍝ Picks up following comments as data
[7]    ⍝<Window
[8]    ⍝  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
[9]    ⍝  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
[10]   ⍝  xmlns:sftools="clr-namespace:Syncfusion.Windows.Tools.Controls;assembly=SyncFusion.Tools.WPF"
[11]   ⍝  Title="Syncfusion Range Slider" SizeToContent="Height" Width="400">
[12]   ⍝  <StackPanel>
[13]   ⍝    <sftools:RangeSliderControl Name="rangeslider" />
[14]   ⍝    <TextBox Name="textbox" MinHeight="25" MinWidth="100"
[15]   ⍝             HorizontalContentAlignment="Right"
[16]   ⍝             VerticalContentAlignment="Bottom"
[17]   ⍝             Background="Turquoise"/>
[18]   ⍝  </StackPanel>
[19]   ⍝</Window>
[20]   :EndSection
[21]
[22]   window←LoadXAML xaml
[23]   (r t)←window.FindName∘⊂¨'rangeslider' 'textbox'
[24]   ⎕USING←,⊂'Syncfusion.Windows.Tools.Controls,Syncfusion/4.5/Syncfusion.tools.WPF.dll'
[25]   r.onRangeChanged←'RangeChanged'
[26]   r.Range←⎕NEW DoubleRange values
[27]   window.Show
[28]
[29]   window.(slider textbox range)←r t r.Range ⍝ expose extra "properties"
     ∇

James Bond or Johnny English?

This year we enrolled our delegates in ‘Spy School’ and gave them the chance to be a spy for a few hours. In an interactive mission that included GPS tracking, teams were given a tablet preloaded with a series of spy related challenges that took place around the local area. The challenges were only activated when the GPS verified the team was in exactly the right location and points were awarded for completing each challenge successfully – the team with most points was the winner. To pile on the pressure, each team had an interactive map showing not only their location but also that of the other teams along with a live scoreboard.

The challenge certainly brought out the competitive side of the delegates and Eastbourne is probably still recovering from the shock of ten teams of APLers carrying out their covert missions around the town centre and promenade. When the final scores were in, it was a very closely run thing with Team Sprat in second place and Team Dover Sole, headed up by a super competitive John Daintree, as the eventual winners. At the final de-briefing we got to see the videos and photos submitted by each team which showed great creativity along with some very over active imaginations! Everyone had a fantastic afternoon with plenty of laughter and not too many injuries (although I am led to believe there may be a broken fingernail or two) and a big thank you to Pretty Clever Events for running the show.

Team Plaice

Team Plaice

Team Dover Sole

Team Dover Sole

Team Dover Sole take a selfie at the  award presentation

Team Dover Sole take a selfie at the award presentation

Coming up…

Today is due to end with the banquet dinner in the Grand Hotel which we’ll try to include in tomorrow’s postcard.

We conclude events tomorrow with two Dyalog and two user presentations in the morning followed by the closing session at which all of Team Dyalog will be present and open to questions. In the afternoon are the remaining Technical Workshops.

Tuesday 23 September at Dyalog ’14

This was originally posted to Catalyst PR’s Facebook page and is reproduced here to make it accessible to people who don’t have Facebook accounts.

For information on the presentations at Dyalog ’14, see http://www.dyalog.com/user-meetings/dyalog14.htm.

Maintainability

The first presentation I would like to highlight from today’s programme is by Gianfranco Alongi from Ericsson AB (Sweden). Those of you who read my posts from Dyalog ’13 last year will know that I am rather taken with Gianfranco’s approach to software development and, in particular, his insistence that it is a software programmer’s sole mission in life to leave a legacy (in the form of code) that is so simple and easy to understand that anyone who comes in later can pick up the ball and run with it, without having to re-invent the wheel and without risking destroying the application. Work smarter – not harder – is his mantra.

Gianfranco’s talk this year was called Let’s Talk about Maintainability!. The background for the talk is that any professional programmer obviously strives for maintainable code, well aware that an unmaintained codebase gradually transforms from a well-tended garden to a dark haunted forest that requires animal sacrifice if left to its own devices. Far too many systems have “that” piece of code – the unmaintained marsh, the mess that causes nausea and elevated blood pressure. Some people swear developers have lost parts of their souls in there and you can hear screaming if you work late enough for long enough…

During the talk Gianfranco explored some of the underlying mechanics of maintainability, presenting a definition of maintainability based on human cognition and sharing a language that might help when talking and reasoning about maintainability. Ultimately any programmer is responsible for maintaining the codebase; However, software entropy is real and we pay in blood, sweat and tears if we choose to ignore it. He insists – and quite rightly so – that maintainability is economics because the Cost of Change (CoC) goes up and up the longer a projects run and it’s measurable as it leads to smaller margins and ultimately smaller profit. Ultimately, you get to a point where it is no longer viable to throw more resources (more people or more overtime) into the mix, and you simply have to re-architect.

The psychology involved in software programming is fascinating! So is the shift from the days of programmers being proud of their ability to write code that other programmers may have difficulty understanding to a world where simplicity in the coding is the ultimate target – in order to address the increasing complexity in the applications.

Statistics

Stephen Mansour (PhD) has taught Statistics at the University of Scranton (U.S.A.) for the past 7 years. He is also working with The Carlisle Group – a company focused exclusively on creating software to support the fast growing mortgage and asset securitisation industry.

The Carlisle Group’s flagship product is CAS, a Collateral Analysis System highly specialised for global asset securitisation markets and used by participants in all facets of the mortgage business, including investment banks, commercial banks, accounting firms, bond insurers and loan originators.

Stephen’s presentation was named Taming Statistics with Limited-Domain Operators and took its offset in a new statistical package he has developed which is using Acre.

(Acre facilitates code management for APLers and was the subject of another talk today. Acre is available as open source software and can be downloaded for free from http://aplwiki.com/acre).

Asked why he felt there was a need for yet another stats package – after all, there are perfectly good packages available in the market, such as R, and even Excel has 87 stats functions, so what exactly is it that a stats package developed in APL can offer that the others can’t, the answer was: Defined Operators!

Stephen then demonstrated the new stats package by making some assumptions with regards to next year’s user meeting and the likelihood of the venue being over-subscribed (or not) based on a number of assumptions and relations.

The package does take advantage of the fact that R already connects into APL and Stephen ended the presentation by saying that the package is currently in beta. He is happy to share, so if you would like to review/try the new stats package please e-mail (Stephen.Mansour@scranton.edu) and specify whether you would like the R version or the native APL version.