<commit_before>/*
 * This file is part of the Electron Orbital Explorer. The Electron
 * Orbital Explorer is distributed under the Simplified BSD License
 * (also called the "BSD 2-Clause License"), in hopes that these
 * rendering techniques might be used by other programmers in
 * applications such as scientific visualization, video gaming, and so
 * on. If you find value in this software and use its technologies for
 * another purpose, I would love to hear back from you at bjthinks (at)
 * gmail (dot) com. If you improve this software and agree to release
 * your modifications under the below license, I encourage you to fork
 * the development tree on github and push your modifications. The
 * Electron Orbital Explorer's development URL is:
 * https://github.com/bjthinks/orbital-explorer
 * (This paragraph is not part of the software license and may be
 * removed.)
 *
 * Copyright (c) 2013, <NAME>
 * 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.
 *
 * 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 HOLDER 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.
 */

#ifndef VECTOR_HH
#define VECTOR_HH

#include <complex>

#include "array.hh"

template <unsigned n, typename T, class V>
class GenericVector : public Array<n,T>, public VectorSpace<T,V>
{
protected:
  GenericVector() {}
  explicit GenericVector(T x) : Array<n,T>(x) {}

public:
  // Allow all elements of a vector to be set with assignment
  const V &operator=(T x)
  {
    for (unsigned i=0; i<n; ++i)
      (*this)[i] = x;
    return *static_cast<V *>(this);
  }
};

template <unsigned n>
class Vector : public GenericVector<n, double, Vector<n> >
{
public:
  Vector() {}
  explicit Vector(double x) : GenericVector<n, double, Vector<n> >(x) {}

  using GenericVector<n, double, Vector<n> >::operator=;
};

// FVector exists only for converting doubles to floats prior to
// uploading vertex data to the GPU.
template <unsigned n>
class FVector : public GenericVector<n, float, FVector<n> >
{
public:
  FVector() {}
  explicit FVector(float x) : GenericVector<n, float, FVector<n> >(x) {}
  explicit FVector(const Vector<n> &x)
  {
    for (int i = 0; i < n; ++i)
      (*this)[i] = x[i];
  }

  using GenericVector<n, float, FVector<n> >::operator=;
};

template <unsigned n>
class CVector : public GenericVector<n, std::complex<double>, CVector<n> >
{
public:
  CVector() {}
  explicit CVector(std::complex<double> x) :
    GenericVector<n, std::complex<double>, CVector<n> >(x) {}

  using GenericVector<n, std::complex<double>, CVector<n> >::operator=;
};

template <class V>
inline V genericBasisVector(unsigned i)<commit_msg>Eliminate a signed vs unsigned comparison warning on OSX<commit_after>/*
 * This file is part of the Electron Orbital Explorer. The Electron
 * Orbital Explorer is distributed under the Simplified BSD License
 * (also called the "BSD 2-Clause License"), in hopes that these
 * rendering techniques might be used by other programmers in
 * applications such as scientific visualization, video gaming, and so
 * on. If you find value in this software and use its technologies for
 * another purpose, I would love to hear back from you at bjthinks (at)
 * gmail (dot) com. If you improve this software and agree to release
 * your modifications under the below license, I encourage you to fork
 * the development tree on github and push your modifications. The
 * Electron Orbital Explorer's development URL is:
 * https://github.com/bjthinks/orbital-explorer
 * (This paragraph is not part of the software license and may be
 * removed.)
 *
 * Copyright (c) 2013, <NAME>
 * 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.
 *
 * 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 HOLDER 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.
 */

#ifndef VECTOR_HH
#define VECTOR_HH

#include <complex>

#include "array.hh"

template <unsigned n, typename T, class V>
class GenericVector : public Array<n,T>, public VectorSpace<T,V>
{
protected:
  GenericVector() {}
  explicit GenericVector(T x) : Array<n,T>(x) {}

public:
  // Allow all elements of a vector to be set with assignment
  const V &operator=(T x)
  {
    for (unsigned i=0; i<n; ++i)
      (*this)[i] = x;
    return *static_cast<V *>(this);
  }
};

template <unsigned n>
class Vector : public GenericVector<n, double, Vector<n> >
{
public:
  Vector() {}
  explicit Vector(double x) : GenericVector<n, double, Vector<n> >(x) {}

  using GenericVector<n, double, Vector<n> >::operator=;
};

// FVector exists only for converting doubles to floats prior to
// uploading vertex data to the GPU.
template <unsigned n>
class FVector : public GenericVector<n, float, FVector<n> >
{
public:
  FVector() {}
  explicit FVector(float x) : GenericVector<n, float, FVector<n> >(x) {}
  explicit FVector(const Vector<n> &x)
  {
    for (int i = 0; i < int(n); ++i)
      (*this)[i] = x[i];
  }

  using GenericVector<n, float, FVector<n> >::operator=;
};

template <unsigned n>
class CVector : public GenericVector<n, std::complex<double>, CVector<n> >
{
public:
  CVector() {}
  explicit CVector(std::complex<double> x) :
    GenericVector<n, std::complex<double>, CVector<n> >(x) {}

  using GenericVector<n, std::complex<double>, CVector<n> >::operator=;
};

template <class V>
inline V genericBasisVector(unsigned i)
{'fraction_non_alphanumeric': 0.09465128474043, 'fraction_numerical': 0.0018353434714210803, 'mean_word_length': 4.316376306620209, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 71, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3155871', 'n_tokens_mistral': 2264, 'n_tokens_neox': 2114, 'n_words': 959}