Pow function

28 views
Skip to first unread message

w4nde...@gmail.com

unread,
Jan 22, 2013, 11:48:12 AM1/22/13
to efficient-java-mat...@googlegroups.com
Hello,

it seems to me that SimpleMatrix has no pow functions like in matlab "A .^ 2" or "A .^ B"


I think this should be added.

w4nderlust

w4nde...@gmail.com

unread,
Jan 22, 2013, 1:24:27 PM1/22/13
to efficient-java-mat...@googlegroups.com
Also a log and a exp functions could be helpful.

Peter A

unread,
Jan 28, 2013, 6:44:38 PM1/28/13
to efficient-java-mat...@googlegroups.com
Hi w4nderlust,

Just created a new issue for your feature requests. They aren't
already included since I wanted to keep the library simple. That
said, they will probably be added for sake of completeness and since
they aren't difficult to implement.

http://code.google.com/p/efficient-java-matrix-library/issues/detail?id=32

Just out of curiosity, what problem requires you to do an element-wise
power operation?

- Peter
--
"Now, now my good man, this is no time for making enemies." —
Voltaire (1694-1778), on his deathbed in response to a priest asking
that he renounce Satan.

w4nde...@gmail.com

unread,
Feb 2, 2013, 8:58:25 PM2/2/13
to efficient-java-mat...@googlegroups.com
Hi Peter,

thanks for your answer, I'll be waiting for the added feature, thanks.
I'm implementing some machine learning stuff and i would find it useful for computing mean squared loss to use the pointwise pow, or for l2 regularization like in matlab:
sum(theta(2:end).^2))

there are probably other ways to do it, but this seems natural to me.

Also the log and exp functions will help me in implementing the sigmoid function for neural networks and logistic regression and the logistic regression cost function like the matlab ones:

function g = sigmoid(z)
g = 1 ./ (1 + exp(-z));
end

J = ((1/m) * sum(- y .* log(sigmoid(X * theta)) - (1 - y) .* log(1 - sigmoid(X * theta)))) + ((lambda/(2*m)) * sum(theta(2:end).^2));

Hope this helps to understand the use case for thos functions.
Reply all
Reply to author
Forward
0 new messages