Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #19201

Matrices

From mhx@iae.nl (Marcel Hendrix)
Subject Matrices
Newsgroups comp.lang.forth
Message-ID <09181308028434@frunobulax.edu> (permalink)
Date 2013-01-27 22:17 +0200
Organization Wanadoo

Show all headers | View raw


I have encountered a problem for which I don't immediately 
see a solution (maybe it won't need one in the Forth sense ;)

Sometimes it is advantageous to NOT compile a word immediately.
Is it possible to have 'delayed compilation?' 

An example is a word A* to multiply two dynamically allocated arrays.
Because the address of the data and the number of rows and columns is
unknown, the addressing of the matrix elements is very inefficient.
In Forth it should be possible to compile A* AFTER it is detected 
that the matrices have been allocated (e.g. the first time A* is
run). At that time many of the @s and !s will resolve to constant
addresses, or at least access fixed rows or columns, and it will be
known that the accesses are aligned or that the strides are 
powers of 2.

Problems: How to detect code is run for the first time? How to detect
that previously compiled code is still valid (no reallocate been done)?

Note that the addresses of the matrices may be passed in locals. 

Assuming that the array syntax is a{{ row column }} @, it is of course
possible to access a{{ efficiently by copying the addresses of rows
and columns into locals (or on the stack) and then access elements 
row- or columnwise. However, as this is for my OPG project I'd like 
to always access the matrices the same, like a{{ row column }} @.

Actually, in OPG the syntax will be a[r,c] where Forth doesn't even 
known if a is a vector or a (2D) matrix (the programmer knows, but 
does not know how to tell the compiler).

-marcel

Back to comp.lang.forth | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Matrices mhx@iae.nl (Marcel Hendrix) - 2013-01-27 22:17 +0200
  Re: Matrices Ron Aaron <rambamist@gmail.com> - 2013-01-28 08:50 +0200
  Re: Matrices Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-01-28 03:11 -0600
    Re: Matrices m.a.m.hendrix@tue.nl - 2013-01-28 01:46 -0800
      Re: Matrices mhx@iae.nl (Marcel Hendrix) - 2013-02-03 12:48 +0200
        Re: Matrices "A. K." <akk@nospam.org> - 2013-02-03 13:27 +0100
        Re: Offline compilation of Forth mhx@iae.nl (Marcel Hendrix) - 2013-02-03 21:17 +0200
  Re: Matrices stephenXXX@mpeforth.com (Stephen Pelc) - 2013-01-28 10:39 +0000
    Re: Matrices m.a.m.hendrix@tue.nl - 2013-01-28 03:33 -0800
  Re: Matrices albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-01-28 14:31 +0000
  Re: Matrices Alex McDonald <blog@rivadpm.com> - 2013-01-28 07:48 -0800
  Re: Matrices Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-01-28 18:06 -0800
  Re: Matrices anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-01-29 09:49 +0000
    Re: Matrices Mark Wills <forthfreak@gmail.com> - 2013-01-29 04:08 -0800
      Re: Matrices m.a.m.hendrix@tue.nl - 2013-01-29 08:22 -0800

csiph-web