help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to convert code m ade ​​in the octave to C?


From: Luke M
Subject: Re: How to convert code m ade ​​in the octave to C?
Date: Mon, 9 Apr 2012 14:13:26 -0700 (PDT)

>My code simulates a perceptron in AI. I need help to pass this particular
piece of code to C.
>How would this code has been done in Octave to C?
>
>yl(1,k) = x(i,:)*w(:,k) + b(k);

As previously mentioned, you could just add a loop and do the vector
multiplication one element at a time (obviously this depends on your C
representation of yl, x, and w):

yl[k] = 0;
for (j = 0; j < n; ++j)
    yl[k] += x[i][j]*w[j][k];
yl[k] += b[k];

Or use some version of BLAS.  Or vectorize, which would help you both in
Octave and C if you use BLAS.

Or, if you're amenable to C++, check out something like Armadillo:
http://arma.sourceforge.net/docs.html#syntax

--
View this message in context: 
http://octave.1599824.n4.nabble.com/How-to-convert-code-made-in-the-octave-to-C-tp4539850p4543864.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]