Daniel@0: function pot = dpot(domain, sizes, T) Daniel@0: % DPOT Make a discrete (sparse) potential. Daniel@0: % pot = dpot(domain, sizes, T, spar) Daniel@0: % Daniel@0: % sizes(i) is the size of the i'th domain element. Daniel@0: % T defaults to all 1s. Daniel@0: Daniel@0: %assert(length(sizes) == length(domain)); Daniel@0: Daniel@0: pot.domain = domain(:)'; % so we can see it when we display Daniel@0: if nargin < 3 Daniel@0: pot.T = myones(sizes); Daniel@0: %pot.T = ones(1,prod(sizes)); % 1D vector Daniel@0: else Daniel@0: if isempty(T) Daniel@0: pot.T = []; Daniel@0: else Daniel@0: if issparse(T) Daniel@0: pot.T = T; Daniel@0: else Daniel@0: pot.T = myreshape(T, sizes); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: pot.sizes = sizes(:)'; Daniel@0: pot = class(pot, 'dpot');