function [V,G] = parvalue(X, Y, W, Gobs)
% PARVALUE Parallel (GPU) version of core MaxEnt value computation
%    
% [V,G] = PARVALUE(X, Y, W, Gobs) where X is the DxN data matrix, Y
% is the 1xN label vector, W is the D+1xL weight matrix, and Gobs
% is the pre-calculated LxD+1 observation portion of the gradient
%
% V is the scalar returned value and G is the LxD+1 gradient
%
% See also SERVALUE
    
% Jerod Weinman
% jerod@acm.org
    
% $Id$


% Put the weight vector into meaningful dimensions: Lx(D+1)
    W = reshape(W, fliplr(size(Gobs)));
    
    
    I = [];
    
    
    % Call cuda_value
    [V, G, gradient_bias] = cuda_value(X, ...                  % DxN
                                       Y, ...                  % Nx1
                                       W, ...                  % LxD+1
                                       Gobs( 1:(end-1),:), ... % DxL
                                       Gobs( end, :), ...      % 1xL
                                       eps('single'), ...
                                       I);                     % Nx1
    

    % Don't bother doing any error checking


    % Reconstruct G as Lx(D+1)
    G = [G' gradient_bias'];

