Skip to content

Add unsigned fixed-point numbers #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 4, 2014
Merged

Add unsigned fixed-point numbers #2

merged 7 commits into from
Aug 4, 2014

Conversation

timholy
Copy link
Member

@timholy timholy commented Jul 27, 2014

CC @StefanKarpinski, since this was your suggestion!

@timholy
Copy link
Member Author

timholy commented Jul 27, 2014

Fixed the error on 0.2. I was forced to test with a less stringent iteration syntax, due to issues with 0.2's range iteration.

uf16
# should asraw be exported?

asraw(x::AbstractFixed) = x.i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be a method of reinterpret.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. This will introduce a one-argument variant of reinterpret, but I agree that makes sense.

@JeffBezanson
Copy link
Collaborator

These data types are kind of cool!

@timholy
Copy link
Member Author

timholy commented Jul 27, 2014

The introduction of scaledual is a bit speculative, but it can essentially double the speed of certain operations. It has the following property:

bd, ad = scaledual(b, a)
b*a == bd*ad

but the RHS might be faster (particularly for floating-point b and an array a of fixed-point numbers).

The idea would be the following: say you're writing imfilter, then

function imfilter(img::AbstractArray, kern::AbstractArray)
    scalefac, imgd = scaledual(eltype(kern), img)
    if scalefac != 1
        kern = scalefac*kern
    end
    # Implement the filtering operation on imgd and kern
end

@timholy
Copy link
Member Author

timholy commented Jul 28, 2014

I added some documentation. If you like scaledual, I can document it, too.

@StefanKarpinski
Copy link

I assume this come from the thing I mentioned on the Color package about considering Uint8 as a way of representing floating-point values 0/255, 1/255, etc.?

@timholy
Copy link
Member Author

timholy commented Jul 28, 2014

Yes indeed! JuliaAttic/Color.jl#42.

@timholy
Copy link
Member Author

timholy commented Aug 2, 2014

Bump. Color is waiting on this, and Images is waiting on Color. (I probably won't merge the Images changes immediately, but I think the Color one is ready to go.)

JeffBezanson added a commit that referenced this pull request Aug 4, 2014
@JeffBezanson JeffBezanson merged commit 4f00cc0 into JuliaMath:master Aug 4, 2014
@timholy timholy deleted the pull-request/42c3d8bf branch August 4, 2014 18:39
@timholy
Copy link
Member Author

timholy commented Aug 4, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants