Subj : Idea - Tensor could be modelled by 2 arrays and a function To : alt.math,alt.sci.physics,comp.programming From : Mr Pixie Date : Mon Aug 22 2005 08:11 pm As a programmer, I try to understand objects in terms of data structures, so here is my idea for how best to code a tensor object. I would be interested to hear comments: 2 arrays, A and B : A is for the real space (covariant) and B is for the dual space (contravariant) The arrays do not have to have the same number of dimensions. In maths, B would be A* The to represent a tensor would be something like: dim A[0..n] ; first array of n dimensions dim B[0..m] ; second array of m dimensions function tensor_transformation (A, B) real { ' tensor transformation rules go here e.g. the Lorentz transformation, or the Euclidean metric (the kronecker delta) return transformation_result; } So, in maths, if we write a tensor e.g. Ta^b then, equating the code to the math, we have: T = 'tensor_transformation' , a = 'A' , b = 'B' so, in math, when we write down a tensor, we are operating on the level of abstraction outside of the function - we are saying nothing about the specific detail when we write down a tensor. The result of the function is/are real number(s). In the case of the Lorentz transformation, the function give the relative 'difference' between the 2 frames - I use the word 'difference' in a very liberal way here - it does not necessarily imply subtraction. (Anybody?) So, for Lorentz the code would be something like: function lorentz(A, B) real, real, real, real; - not sure this would compile! Anybody know the best way around this? { ' tensor transformation detail for La^b - L is the lorentz tensor, usually written as 'gamma' return dx, dy, dz, dt; } In the case of the Lorentz transformation, the function returns the real numbers dx, dy, dz, dt Note : in maths there is also another level of abstraction going on : in the previous (lorentz) tensor, we had La^b but a = {x0,x1,x2,x3) and b={x'0, x'1, x'2, x'3) , so a is actually 4 numbers and so is b !!! The Lorentz transformation La^b is the 'relative difference' between the 2 frames i.e. real number(s) I think this is all about right... - can anybody spot flaws I have missed? Can anybody fill be in on the code for the Lorentz transformation detail?? - it should be a straight-forward matrix transformation .