// Path: src/main/java/pitt/search/semanticvectors/vectors/ComplexVector.java
// public static enum Mode {
//   /** Uses a nonnegative 16 bit short for each phase angle.  The value -1 is reserved for
//    * representing the complex number zero, i.e., there is no entry in this dimension. */
//   POLAR_DENSE,
//   /** Uses a pair of 16 bit shorts for each (offset, phase angle) pair. */
//   POLAR_SPARSE,
//   /** Uses a pair of 32 bit floats for each (real, imaginary) complex coordinate. */
//   CARTESIAN,
//   /** As above, but with normalization to unit length and the hermitian scalar product
//    *  instead of the alternatives proposed by Plate */
//   HERMITIAN
// }


import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.RAMDirectory;
import org.junit.Test;
import static pitt.search.semanticvectors.MyTestUtils.assertFloatArrayEquals;
import static pitt.search.semanticvectors.vectors.ComplexVector.Mode;
import junit.framework.TestCase;
import static org.junit.Assert.assertArrayEquals;
/**
   Copyright (c) 2011, the SemanticVectors AUTHORS.

   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:

   * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

   * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following
   disclaimer in the documentation and/or other materials provided
   with the distribution.

   * Neither the name of the University of Pittsburgh nor the names
   of its contributors may be used to endorse or promote products
   derived from this software without specific prior written
   permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

package pitt.search.semanticvectors.vectors;






/**
 * Tests for {@code ComplexVector} class.  Many of these tests use {@code ComplexVector#toString}
 * to check correct results.  This is somewhat ad hoc and any change in the debug string
 * representation will likely cause breakages.  Be warned!
 */
public class ComplexVectorTest extends TestCase {

  private static final double TOL = 0.001;

  @Test 
  public void testGenerateRandomVector() {
    // Generate random vector
    ComplexVector cv1 = (ComplexVector) VectorFactory.generateRandomVector(
        VectorType.COMPLEX, 5, 2, new Random(0));
    assertArrayEquals(new short[] {0, 13622, 4, 9934}, cv1.getSparseOffsets());
// Path: src/main/java/pitt/search/semanticvectors/vectors/ComplexVector.java
// public static enum Mode {
//   /** Uses a nonnegative 16 bit short for each phase angle.  The value -1 is reserved for
//    * representing the complex number zero, i.e., there is no entry in this dimension. */
//   POLAR_DENSE,
//   /** Uses a pair of 16 bit shorts for each (offset, phase angle) pair. */
//   POLAR_SPARSE,
//   /** Uses a pair of 32 bit floats for each (real, imaginary) complex coordinate. */
//   CARTESIAN,
//   /** As above, but with normalization to unit length and the hermitian scalar product
//    *  instead of the alternatives proposed by Plate */
//   HERMITIAN
// }


// Path: src/test/java/pitt/search/semanticvectors/vectors/ComplexVectorTest.java
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.RAMDirectory;
import org.junit.Test;
import static pitt.search.semanticvectors.MyTestUtils.assertFloatArrayEquals;
import static pitt.search.semanticvectors.vectors.ComplexVector.Mode;
import junit.framework.TestCase;
import static org.junit.Assert.assertArrayEquals;

/**
   Copyright (c) 2011, the SemanticVectors AUTHORS.

   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:

   * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

   * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following
   disclaimer in the documentation and/or other materials provided
   with the distribution.

   * Neither the name of the University of Pittsburgh nor the names
   of its contributors may be used to endorse or promote products
   derived from this software without specific prior written
   permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

package pitt.search.semanticvectors.vectors;






/**
 * Tests for {@code ComplexVector} class.  Many of these tests use {@code ComplexVector#toString}
 * to check correct results.  This is somewhat ad hoc and any change in the debug string
 * representation will likely cause breakages.  Be warned!
 */
public class ComplexVectorTest extends TestCase {

  private static final double TOL = 0.001;

  @Test 
  public void testGenerateRandomVector() {
    // Generate random vector
    ComplexVector cv1 = (ComplexVector) VectorFactory.generateRandomVector(
        VectorType.COMPLEX, 5, 2, new Random(0));
    assertArrayEquals(new short[] {0, 13622, 4, 9934}, cv1.getSparseOffsets());
    assertEquals(Mode.POLAR_SPARSE, cv1.getOpMode());