-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes from last year, includes reference mat’s & some unremembered improvements
- Loading branch information
Showing
24 changed files
with
1,370 additions
and
405 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "InfIntStream.h" | ||
#include <algorithm> | ||
|
||
using namespace InfIntStream_NS; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
#ifndef INFUINTSEQUENCE_H | ||
#define INFUINTSEQUENCE_H | ||
|
||
using namespace BitSequence_NS; | ||
|
||
namespace InfIntSequence_NS { | ||
|
||
template <typename ENDIAN> | ||
class InfUintSequence { | ||
BitStream_NS::BitStream<ENDIAN> bseq; | ||
|
||
public: | ||
InfUintSequence(byte* const bit_first, byte* const bit_last); | ||
operator bool() const; | ||
|
||
bool skip_next(); | ||
bool has_next() const; | ||
template <typename UINT> | ||
bool peek_next(UINT& value) const; | ||
|
||
|
||
// TODO must implement bits-remaining checks | ||
template <typename UINT> | ||
bool operator<<(const UINT& u) { | ||
UINT n; | ||
bool o; | ||
if (u < 3) { | ||
// Treat values <3 as having the most sig. bit | ||
// at bit pos. CHAR_BIT*sizeof(UINT) | ||
n = CHAR_BIT*sizeof(UINT); | ||
o=false; | ||
} else { | ||
n = u; | ||
for (std::size_t i=1; i<CHAR_BIT*sizeof(UINT); i<<=1) { | ||
n |= n>>i; | ||
} | ||
n^=(n>>1); | ||
o = u & (n>>1); | ||
n = get_bit_pos(n); | ||
} | ||
if (!bseq.has_next(2*n+o-3)) return false; | ||
bseq.set(true,n+o-3); | ||
bseq << false; | ||
bseq << !o; | ||
bseq.set(u, n-2); | ||
|
||
return *this; | ||
} | ||
template <typename UINT> | ||
bool operator>>(UINT& u) { | ||
std::size_t n; | ||
bool o; | ||
n = bseq.get(true); | ||
bseq.skip_next(); | ||
bseq >> o; | ||
|
||
u=0; | ||
bseq.get(u,n+o); | ||
u+=(UINT(3)+o)<<n; | ||
} | ||
}; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef DIVIDE_NON_NEGATIVE_REMAINDER_H | ||
#define DIVIDE_NON_NEGATIVE_REMAINDER_H | ||
|
||
#include <limits> | ||
|
||
template <typename SINT> | ||
void divide_w_nneg_remainder(const SINT& dividend, const SINT& divisor, | ||
SINT& quotient, SINT& remainder) { | ||
quotient = dividend / divisor; | ||
remainder = dividend % divisor; | ||
if ((!std::numeric_limits<SINT>::is_specialized || std::numeric_limits<SINT>::is_signed) && remainder<0) { | ||
--quotient; | ||
remainder+=divisor; | ||
} | ||
} | ||
template <typename SINT> | ||
SINT quotient_w_nneg_remainder(const SINT& dividend, const SINT& divisor) { | ||
SINT quotient, tmp; | ||
divide_w_pos_remainder(dividend, divisor, quotient, tmp); | ||
return quotient; | ||
} | ||
template <typename SINT> | ||
SINT nneg_remainder(const SINT& dividend, const SINT& divisor) { | ||
SINT tmp, remainder; | ||
divide_w_pos_remainder(dividend, divisor, tmp, remainder); | ||
return remainder; | ||
} | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.