function U = value(F,A)
% VALUE Value of an assignment to the factor
%
% U = VALUE(F,A) where A is a vector of indices to the factor table

  
% WORDFACTOR.VALUE

    
% Jerod Weinman
% jerod@acm.org
    
% $Id: value.m 1 2009-06-17 20:04:43Z weinman $
 
% Jerod Weinman
% jerod@acm.org
% Copyright 2006, 2008, 2009, 2011
 
%    This file is part of VIDI.
%
%    VIDI is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    VIDI is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with VIDI.  If not, see <http://www.gnu.org/licenses/>.

  if length(A)~=(size(F.words,2)+1)
	error('Illegal assignment');
  end;
  
  % No value (log 1 = 0) for non-word
  if A(end)==1
	U = 0;
  else
	
	ww = all(F.words == A(ones(1,numwords(F)),1:end-1),2);
	
	if ~any(ww)
	  %error('Invalid assignment');
      U = -Inf;
    else
      U = F.wordtable(ww);
	end;
  end;
