Julia likes matrices and it just so happens I have a small Linear Algebra example written for MATLAB. So, I transmogrified it to run in Julia. There are a bunch of syntactic differences...

When I wrote the code for MATLAB, I chose to start with a 6x7 matrix where the 7th column was the value vector for the simultaneous equations. Hence the bit where I have to extract the 7th column.

using Printf

# A football stadium has a capacity of 100,000 attendees

# Ticket prices:

# Student = $25

# Alumni = $40

# Faculty = $60

# Public = $70

# Veterans = $32

# Guests = $ 0

# A full capacity game netted $4,897,000

# Let S = number of students, A = number of alumni, F = number of faculty

# P = number of public, V = number of veterans, G = number of guests

# S A F P V G = value

M = [ 1 1 1 1 1 1 100000 # total number of attendees

25 40 60 70 32 0 4897000 # total revenue

0 1 -1 0 0 0 11000 # 11000 more alumni than faculty

0 1 0 1 -10 0 0 # public + alumni = 10 * veterans

-1 1 1 0 0 0 0 # alumni + faculty = students

1 0 1 0 -4 -4 0] # faculty + students = 4 (guests + veterans)

A = M[:,1:6] # extract 6x6 matrix

B = M[:,7] # extract value column vector

P = (M[2,1:6])' # ticket price by attendee type

R = inv(A)*B # compute number of attendees by type

T = sum(R) # check total attendees = 100,000 CHECK

U = P.*R # total revenue = 4,897,000 CHECK

V = R'.*P # revenue by attendee type - transpose R from 6x1 to 1x6

# then do element by element multiplication

labels = ["Students", "Alumni", "Faculty", "Public", "Veterans", "Guests"]

for i in 1:6

@printf("%-8s %7d @ %2d %7d\n",labels[i],

round(R[i]),

M[2,i],

round(V[i]))

end

@printf("\nTotals %7d %8d\n",round(T), round(sum(V)))

[/font]

Not that it will be efficient on such a small problem but the next step is to shove the computing off to the GPU - just for a drill.