Opis forum
Vector::Vector(int ArraySize) { this->Size = 0; this->Capacity = ArraySize; this->VectorArray = new unsigned char[this->Capacity]; } void Vector::PutSignIntoArray(unsigned char Sign) { if(this->Size < this->Capacity) { this->VectorArray[this->Size]= Sign; this->Size++; //cout << "Dodano Element :" << Sign<< "\n"; } else { int NewCapacity=this->Size+5; Vector MyVector3(NewCapacity); for(int counter = 0; counter <= this->Size; counter++) { if(counter == this->Size) { MyVector3.VectorArray[counter] = Sign; MyVector3.Size++; } else { MyVector3.VectorArray[counter] = this->ReadArrayAt(counter); MyVector3.Size++; } } cout << "\nDodano Element (zostala rozszerzona tablica)\n\n"; delete[] this->VectorArray; this->VectorArray = new unsigned char[NewCapacity]; this->Capacity = NewCapacity; this->Size = 0; for(int counter2 = 0; counter2 < MyVector3.Size; counter2++) { this->VectorArray[counter2]=MyVector3.ReadArrayAt(counter2); this->Size++; } } } void Vector::AddVectorMMX(Vector VectorToAdd) { __m64* vektor1; __m64* vektor2; if(this->Size >= VectorToAdd.Size) { for(int counter = 0; counter< this->Size; counter+=8) { vektor1 = (__m64*)&this->VectorArray[counter]; vektor2 = (__m64*)&VectorToAdd.VectorArray[counter]; *vektor1 = _mm_adds_pu8(*vektor1,*vektor2); } _mm_empty(); } } void Vector::AddVectorSSE(Vector VectorToAdd) { __m128i vektor4; __m128i vektor5; if(this->Size >= VectorToAdd.Size) { for(int counter=0; counter < this->Size; counter+=16) { vektor4 = _mm_loadu_si128((__m128i*)&this->VectorArray[counter]); vektor5 = _mm_loadu_si128((__m128i*)&VectorToAdd.VectorArray[counter]); _mm_storeu_si128((__m128i*)&this->VectorArray[counter], _mm_add_epi8(vektor5, vektor4)); } } }
Offline