00001 //**************************************************** 00002 // April, 1993, University of Illinois 00003 // Copyright (C) 1993, 1994 Tianlin Wang 00004 /* Copyright (C) 1994-2003 Matvec Development Team. 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with this library; if not, write to the Free 00018 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00019 MA 02111-1307, USA 00020 */ 00021 00022 #include "util.h" 00023 #include "chromosome.h" 00024 00025 namespace matvec { 00026 00027 /////////////////////////// Locus class ///////////////////////////// 00028 00029 const Locus& Locus::operator=(const Locus& A) 00030 { 00031 if (this != &A) { 00032 allele = A.allele; 00033 effect = A.effect; 00034 } 00035 return *this; 00036 } 00037 00038 /////////////////////////// Chromosome class ///////////////////////////// 00039 00040 const Chromosome& Chromosome::operator=(const Chromosome& A) 00041 { 00042 copyfrom(A); 00043 return *this; 00044 } 00045 00046 void Chromosome::copyfrom(const Chromosome& A) 00047 { 00048 if (this == &A) return; 00049 chrom_id = A.chrom_id; 00050 chrom_freq = A.chrom_freq; 00051 resize(A.numloci); 00052 for (unsigned i=0; i<numloci; i++) locus[i] = A.locus[i]; 00053 } 00054 00055 void Chromosome::resize(const unsigned nl) 00056 { 00057 if (numloci == nl) return; 00058 numloci = nl; 00059 if (locus) { 00060 delete locus; 00061 locus = 0; 00062 } 00063 if (numloci>0){ 00064 locus = new Locus [numloci]; 00065 } 00066 else { 00067 locus = 0; 00068 } 00069 assert(locus); 00070 } 00071 } //////// end of namespace matvec 00072
1.2.16