public static function cardinalityEqualsVariety($set) {
		$tonesInSet = \ianring\BitmaskUtils::countOnBits($set);

		// this is every possible way that a set of N things can be arranged, excluding rotational duplicates.
		$patterns = self::getUniqueSubsetPatterns($tonesInSet);

		foreach ($patterns as $pattern) {
			$cardinality = \ianring\BitmaskUtils::countOnBits($pattern);

			if ($pattern == 0) {
				continue;
			}
			$mapped = \ianring\BitmaskUtils::mapTo($pattern, $set); // using the pattern like [0,1,2], we map it to tones in the set, like [C,D,E]

			// this fancy method does a lot of work to get the number of different interval patterns
			$variety = self::getVariety($set, $mapped);

			// does cardinality equal variety? Here's where we find out.
			if ($cardinality !== $variety) {
				return false;
			}
		}

		// if we've tried every pattern and CV is true for them all, then we have a winner!
		return true;
	}
public static function cardinalityEqualsVariety($set) {
		$tonesInSet = \ianring\BitmaskUtils::countOnBits($set);

		// this is every possible way that a set of N things can be arranged, excluding rotational duplicates.
		$patterns = self::getUniqueSubsetPatterns($tonesInSet);

		foreach ($patterns as $pattern) {
			$cardinality = \ianring\BitmaskUtils::countOnBits($pattern);

			if ($pattern == 0) {
				continue;
			}
			$mapped = \ianring\BitmaskUtils::mapTo($pattern, $set); // using the pattern like [0,1,2], we map it to tones in the set, like [C,D,E]

			// this fancy method does a lot of work to get the number of different interval patterns
			$variety = self::getVariety($set, $mapped);

			// does cardinality equal variety? Here's where we find out.
			if ($cardinality !== $variety) {
				return false;
			}
		}

		// if we've tried every pattern and CV is true for them all, then we have a winner!
		return true;
	}
public static function cardinalityEqualsVariety ( $ set ) { $ tonesInSet = \ ianring \ BitmaskUtils :: countOnBits ( $ set ) ; // this is every possible way that a set of N things can be arranged, excluding rotational duplicates. $ patterns = self :: getUniqueSubsetPatterns ( $ tonesInSet ) ; foreach ( $ patterns as $ pattern ) { $ cardinality = \ ianring \ BitmaskUtils :: countOnBits ( $ pattern ) ; if ( $ pattern == 0 ) { continue ; } $ mapped = \ ianring \ BitmaskUtils :: mapTo ( $ pattern , $ set ) ; // using the pattern like [0,1,2], we map it to tones in the set, like [C,D,E] // this fancy method does a lot of work to get the number of different interval patterns $ variety = self :: getVariety ( $ set , $ mapped ) ; // does cardinality equal variety? Here's where we find out. if ( $ cardinality !== $ variety ) { return false ; } } // if we've tried every pattern and CV is true for them all, then we have a winner! return true ; }
Cardinality equals variety for a set, if you can choose any N members of the set, and the number of different interval patterns
between the notes in that subset and all SCALAR TRANSPOSITIONS of that subset is also N.

For example, say your pitch class set is the diatonic major scale. [C,D,E,F,G,A,B]
You can choose any N notes, so if N is 3 we could choose the subset [C,E,F].
The scalar transpositions are not the same as chromatic transpositions. A chromatic transposition would be [C#,E#,F#], whereas a
scalar transposition up one step from [C,E,F] is [D,F,G] - the tones are all within the steps of the scale (or set).

We look at the interval patterns present between the notes for all scalar transpositions. In the case of a diatonic scale, we'll
find there are 3 different patterns: [M3,m2], [m3,M2], [m3,M2]. Since there are 3 interval patterns and the cardinality of the set
is also 3, we can assert that for THIS SUBSET the diatonic scale, CARDINALITY EQUALS VARIETY.

If a set exhibits this behaviour for all the possible subsets, then the whole set has the "Cardinality Equals Variety" property.

Some texts also mention the third interval between the last and first note, e.g. [M3,m2,P5] because there's a perfect 5 between the
F and C. Since that last "wrap around" interval is just 12 minus the sum of the others, wen can omit it without any ill effects.

As a counter-example, look at the whole tone scale. Because of its total symmetry it will have the same pattern of intervals for all
scalar transpositions of any subset; the variety will always be 1 regardless of the cardinality. Therefore this function will return
false for the whole tone scale.

Since this is an "is it true" function, we can exit early with FALSE if any combination is found where C!=V. But in those rare cases
where it is true, we may need to do a lot of calculations to return a TRUE.

@return boolean returns true if cardinality equals variety for this set
Cardinality equals variety for a set if you can choose any N members of the set and the number of different interval patterns between the notes in that subset and all SCALAR TRANSPOSITIONS of that subset is also N .