Home > wafo > wstats > cdr.m

# cdr

## PURPOSE

Complete Defining Relation

## SYNOPSIS

[I0,R] = cdr(I,varargin)

## DESCRIPTION

``` CDR Complete Defining Relation

CALL:  I0 = cdr(I);

I0 = Matrix of defining relations including all words.
R  = Integer defining the resolution.
I  = Matrix of generators.

CDR uses the matrix of P generators to compute the complete defining
relation for the design. This is useful to determine the confounding
patterns of a two-level fractional design. The resolution of the design
is also identified as the length of the shortest word in the defining
relation. Any P words of I0 may be used as a genrator for the design.

Example:
I = sudg(8,4);
D = ffd(8,I);    % Fractional design for 8 variables in 2^(8-4) runs.
[I0,r] = cdr(I); % with a resolution IV.

## CROSS-REFERENCE INFORMATION

This function calls:
 cl2cnr Column Label to Column Number cnr2cl Column Number to Column Label. error Display message and abort function. ischar True for character array (string). nan Not-a-Number. setxor Set exclusive-or. sortrows Sort rows in ascending order. warning Display warning message; disable or enable warning messages.
This function is called by:
 alias Alias structure of a fractional design.

## SOURCE CODE

```001 function [I0,R] = cdr(I,varargin)
002 %CDR Complete Defining Relation
003 %
004 % CALL:  I0 = cdr(I);
005 %
006 %  I0 = Matrix of defining relations including all words.
007 %  R  = Integer defining the resolution.
008 %  I  = Matrix of generators.
009 %
010 % CDR uses the matrix of P generators to compute the complete defining
011 % relation for the design. This is useful to determine the confounding
012 % patterns of a two-level fractional design. The resolution of the design
013 % is also identified as the length of the shortest word in the defining
014 % relation. Any P words of I0 may be used as a genrator for the design.
015 %
016 % Example:
017 %   I = sudg(8,4);
018 %   D = ffd(8,I);    % Fractional design for 8 variables in 2^(8-4) runs.
019 %   [I0,r] = cdr(I); % with a resolution IV.
020 %
022
023 % Tested on: Matlab 5.3
024 % History:
025 % By Per A. Brodtkorb 16.03.2001
026
027
028
029 error(nargchk(1,2,nargin))
030
031 if ischar(I),
032  I = cl2cnr(I); % Transform from a column label into column nr.
033 end
034
035 I1 = abs(I);
036 p = size(I1,1);
037 k = max(I1(:));
038 if k-p<2
039   warning('This is not a design generator!')
040   I0 = I;
041 elseif p>1,
042   m = 2^p-1;
043   n = size(I1,2);
044
045   sgn = sign(I);
046   sgn(sgn==0)=1;
047   sgn = prod(sgn,2);
048   sgn0 = ones(m,1);
049
050   I0 = zeros(m,k);
051   iz = 0;
052   for ix = 1:p,
053     iz      = iz+1;
054     I0(iz,k+1-n:k) = sort(I1(ix,:));
055     sgn0(iz) = sgn(ix);
056
057     iz0     = iz;
058     sgn0(iz0+1:2*iz0-1) = sgn0(iz0)*sgn0(1:iz0-1);
059     for iy = 1:iz0-1,
060       iz = iz+1;
061      % find values that are not in the intersection of I0(iz0,:) and I0(iy,:)
062       tmp = setxor(I0(iz0,:),I0(iy,:));
063       I0(iz,k+1-length(tmp):k)   = tmp;
064     end
065   end
066   I0(:,k)= I0(:,k).*sgn0;
067 else
068   I0 = I;
069 end
070 if 1,
072   [ix,iy] = find(I0~=0);
073   if ~isempty(iy)
074     ix = min(iy);
075     I0 = I0(:,ix:end);
076     k = size(I0,2);
077   end
078 else
079   for ix=1:k,
080     if any(I0(:,ix)~=0), I0 = I0(:,ix:k); k = k-ix+1; break,end
081   end
082 end
083
084 if nargout>1,
085   % Length of the shortest word in the defining relation
086   % is equal to the resolution.
087   R = size(I0,2);
088   [ix,iy] = find(I0==0);
089   if any(iy),
090     R = R-max(iy(:));
091   end
092 end
093
094 I0 = sortrows(I0);
095
096
097 k1 = find(I0==0);
098 if any(k1),
099   % Sort so that zeros comes last on each row.
100   I0(k1) = NaN;
101   I0 = sort(I0,2);
102   I0(find(isnan(I0)))=0;
103 end
104
105 if nargin<2 & k<=50, % secret option
106  I0 = cnr2cl(I0); % Transform into a column label
107 end
108 return
109
110
111
112```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003