/*---------------------------------------------------------------------------* * IT++ * *---------------------------------------------------------------------------* * Copyright (c) 1995-2004 by Tony Ottosson, Thomas Eriksson, Pål Frenger, * * Tobias Ringström, and Jonas Samuelsson. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation under the terms of the GNU General Public License is hereby * * granted. No representations are made about the suitability of this * * software for any purpose. It is provided "as is" without expressed or * * implied warranty. See the GNU General Public License for more details. * *---------------------------------------------------------------------------*/ /*! \file \brief Implementation of binary sequence classes and functions. \author Tony Ottosson and Pål Frenger 1.6 2004/01/30 11:29:24 */ #include "base/itassert.h" #include "comm/sequence.h" #include "base/specmat.h" namespace itpp { LFSR::LFSR(const bvec &connections) { set_connections(connections); } LFSR::LFSR(const ivec &connections) { set_connections(connections); } void LFSR::set_connections(const bvec &connections) { short N=connections.size()-1; memory.set_size(N, true); // Should this be true??? Connections=connections.right(N); } void LFSR::set_connections(const ivec &connections) { bvec temp=oct2bin(connections); short N=temp.size()-1; memory.set_size(N, true); // Should this be true??? Connections=temp.right(N); } void LFSR::set_state(const bvec &state) { assert(state.length()==memory.size()); memory=state; } void LFSR::set_state(const ivec &state) { bvec temp=oct2bin(state,1); assert(temp.length()>=memory.size()); memory=temp.right(memory.size()); } bvec LFSR::shift(int no_shifts) { assert(no_shifts>0); bvec temp(no_shifts); for (int i=0;i0); bvec temp(no_shifts); for (int i=0;i