Hi all, I searched the web and didn't find anything useful, but is there some trick to clip a signed int to, say, +-15 or +-16, maybe using some bit pattern processing? Best regards, Andre

0 |

1/14/2015 2:33:21 PM

On Wed, 14 Jan 2015 15:33:21 +0100, Andre <lodwig@pathme.de> wrote: >Hi all, > >I searched the web and didn't find anything useful, >but is there some trick to clip a signed int to, say, >+-15 or +-16, maybe using some bit pattern processing? > >Best regards, > >Andre if (x(n) > UpperLimit) x(n) = UpperLimit; if (x(n) < LowerLimit) x(n) = LowerLimit; Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com

0 |

1/14/2015 6:27:39 PM

On 14.01.15 15.33, Andre wrote: > I searched the web and didn't find anything useful, > but is there some trick to clip a signed int to, say, > +-15 or +-16, maybe using some bit pattern processing? +-15 or +-16 is an odd range. You won't get this working by bit operations. And even other saturation logic is not that trivial. That's why GPUs have hard coded hardware for this purpose. The fastest way without dedicated hardware is compare followed by conditional memory access if your CPU supports it. There you might succeed with 4 machine instructions. Without conditional memory access (e.g. x86) you won't come around branches with probably not that good branch prediction. Of course, you can use bit logic, but I am in doubt that there is any benefit, besides obfuscation of course. short x, y; x = y = i; x |= x << 6; y &= y << 6; x |= x << 3; y &= y << 3; x |= x << 1; y &= y << 1; x |= x << 1; y &= y << 1; x &= ~y; y = i; x >>= 15; y >>= 15; printf(" - %x, %x, %x; %x - ", x, y, x & ~y & 15); i |= x & ((y & -16) | (~y & 15)); i &= ~x | ((y | 15) & (~y | -16)); Now i is restricted to -16..15. This is for 16 bit input. But it works similar for 32 bit input. You only need another shift operation above. Marcel

0 |

1/14/2015 7:04:42 PM

On Wed, 14 Jan 2015 15:33:21 +0100, Andre wrote: > Hi all, > > I searched the web and didn't find anything useful, but is there some > trick to clip a signed int to, say, +-15 or +-16, maybe using some bit > pattern processing? In what hardware? What are you really trying to do? There are some handy tricks you can do if n is equal to one less than your word width, the number is a result of an add or subtract (so there's an overflow bit available) and you're willing to program in assembly language. There are some handy tricks you can do if n is equal to one less than your word width and you're using an integer DSP with an overflow register (they come with different names, but yea -- that). There are some handy tricks you can do if you're doing FPGA or logic design and the number is the result of an add (or a series thereof). All these sets of handy tricks are different. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com

0 |

1/14/2015 11:16:54 PM

For FPGAs you can either check the whole value or better just the few MSB bits to be ddiscarded as follows: -- checking one MSB bit and clipping, assuming data1 is 17 bits signed if data1(16:15) = “00” or data1(16:15) = “11” then data <= data1(15 downto 0); elsif data1(16) = '1' then data <= -32767; else data <= +32767; end if; Kaz _____________________________ Posted through www.DSPRelated.com

0 |

1/14/2015 11:43:06 PM

Andre <lodwig@pathme.de> wrote: > I searched the web and didn't find anything useful, > but is there some trick to clip a signed int to, say, > +-15 or +-16, maybe using some bit pattern processing? If you want saturation arithmetic, so clip and the largest and smallest values, sense overflow/underflow (assuming add or subtract) and process accordingly. Some years ago, I was trying to do this in XC4000 series FPGAs, which have a neat trick. I don't think this works in later ones. The XC4000 carry logic is separate from the logic generating the sum (or difference). Also, there is one extra entry in the LUTs that are needed for adding. I could test for overflow or underflow (not both) and feed the resulting signal into the otherwise unused LUT input to generate the largest or smallest value. (In most cases I knew which way it would go.) In the case where it could either overflow or underflow, I would feed one signal to the following pipeline stage, which also had an extra input. That trick went away with the XC4000, and I don't know any quite as good for later series. For software, again detect the overflow and use conditional load (faster than unpredicted branch) to load the right value. Again, you have to know which way it goes, or use two such tests. For other cases, you can use bit masks to detect values. That is sometimes faster than compare instructions. -- glen

0 |

1/15/2015 1:46:33 AM

Dear all, thanks for all the responses, I was just a bit upset that comparing to upper and lower limit is my best option. Hardware is a blackfin DSP, I noticed that a sharc has a native clip instruction... best regards, Andre On 15.01.2015 00:43, kaz wrote: > For FPGAs you can either check the whole value or better just the few MSB > bits to be ddiscarded as follows: > > -- checking one MSB bit and clipping, assuming data1 is 17 bits signed > if data1(16:15) = “00” or data1(16:15) = “11” then > data <= data1(15 downto 0); > elsif data1(16) = '1' then > data <= -32767; > else > data <= +32767; > end if; > > > Kaz > > _____________________________ > Posted through www.DSPRelated.com >

0 |

1/15/2015 8:51:51 AM

On 15.01.2015 00:43, kaz wrote: > For FPGAs you can either check the whole value or better just the few MSB > bits to be ddiscarded as follows: > > -- checking one MSB bit and clipping, assuming data1 is 17 bits signed > if data1(16:15) = “00” or data1(16:15) = “11” then > data <= data1(15 downto 0); > elsif data1(16) = '1' then > data <= -32767; > else > data <= +32767; > end if; > > > Kaz > > _____________________________ > Posted through www.DSPRelated.com > Dear all, thanks for all the responses, I was just a bit upset that comparing to upper and lower limit is my best option. Hardware is a blackfin DSP, I noticed that a sharc has a native clip instruction... best regards, Andre

0 |

1/15/2015 8:52:11 AM

On 01/15/2015 04:52 PM, Andre wrote: > On 15.01.2015 00:43, kaz wrote: >> For FPGAs you can either check the whole value or better just the few MSB >> bits to be ddiscarded as follows: >> >> -- checking one MSB bit and clipping, assuming data1 is 17 bits signed >> if data1(16:15) = “00” or data1(16:15) = “11” then >> data <= data1(15 downto 0); >> elsif data1(16) = '1' then >> data <= -32767; >> else >> data <= +32767; >> end if; >> >> >> Kaz >> >> _____________________________ >> Posted through www.DSPRelated.com >> > > Dear all, > > thanks for all the responses, I was just a bit upset that comparing to > upper and lower limit is my best option. > > Hardware is a blackfin DSP, I noticed that a sharc has > a native clip instruction... > > best regards, > > Andre > Are you sure there isn't an option to saturate to any selected bit position in a Blackfin? Its years since I touched one, but I thought it had that. Regards, Steve

0 |

1/15/2015 2:11:01 PM

On Thu, 15 Jan 2015 09:52:11 +0100, Andre <lodwig@pathme.de> wrote: >On 15.01.2015 00:43, kaz wrote: >> For FPGAs you can either check the whole value or better just the few MSB >> bits to be ddiscarded as follows: >> >> -- checking one MSB bit and clipping, assuming data1 is 17 bits signed >> if data1(16:15) = “00” or data1(16:15) = “11” then >> data <= data1(15 downto 0); >> elsif data1(16) = '1' then >> data <= -32767; >> else >> data <= +32767; >> end if; >> >> >> Kaz >> >> _____________________________ >> Posted through www.DSPRelated.com >> > >Dear all, > >thanks for all the responses, I was just a bit upset that comparing to >upper and lower limit is my best option. > >Hardware is a blackfin DSP, I noticed that a sharc has >a native clip instruction... It is probably an asymetric 2's complement clip, which most are. If you want an symmetric clip like you previously described, you pretty much have to compare, although the "compare" can take different tricky forms depending on what you're doing.. >best regards, > >Andre > Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com

0 |

1/15/2015 4:51:20 PM

On Wednesday, 14 January 2015 09:33:25 UTC-5, Andre wrote: > Hi all, > > I searched the web and didn't find anything useful, > but is there some trick to clip a signed int to, say, > +-15 or +-16, maybe using some bit pattern processing? > > Best regards, > > Andre What range are your numbers in? If you are using 16 bits integers why not just a table-lookup? Than your code becomes: y = table((unsign int)X);

0 |

1/15/2015 5:18:25 PM

Andre wrote: > thanks for all the responses, I was just a bit upset that comparing to > upper and lower limit is my best option. > > Hardware is a blackfin DSP, I noticed that a sharc has > a native clip instruction... Blackfin has a saturating shift, so if you actually want to clip to [-16,+15] ("2's complement, 5 bits"), you could do things like r0 = r0 << 26 (s); r0 = r0 >>> 26; Blackfin also has MIN and MAX that make clipping to any interval trivial if you have some registers to spare. Stefan

0 |

1/15/2015 5:43:58 PM

>On Thu, 15 Jan 2015 09:52:11 +0100, Andre <lodwig@pathme.de> wrote: > >>On 15.01.2015 00:43, kaz wrote: >>> For FPGAs you can either check the whole value or better just the few MSB >>> bits to be ddiscarded as follows: >>> >>> -- checking one MSB bit and clipping, assuming data1 is 17 bits signed >>> if data1(16:15) = “00” or data1(16:15) = “11” then >>> data <= data1(15 downto 0); >>> elsif data1(16) = '1' then >>> data <= -32767; >>> else >>> data <= +32767; >>> end if; >>> >>> >>> Kaz >>> >>> _____________________________ >>> Posted through www.DSPRelated.com >>> >> >>Dear all, >> >>thanks for all the responses, I was just a bit upset that comparing to >>upper and lower limit is my best option. >> >>Hardware is a blackfin DSP, I noticed that a sharc has >>a native clip instruction... > >It is probably an asymetric 2's complement clip, which most are. If >you want an symmetric clip like you previously described, you pretty >much have to compare, although the "compare" can take different tricky >forms depending on what you're doing.. > >>best regards, >> >>Andre >> > >Eric Jacobsen >Anchor Hill Communications >http://www.anchorhill.com > yes symmetric clipping requires check on full value and so may waste resource. asymmetric is easier and my above example is "almost symmetric" except for value of -32768 which will pass through but that will very occasional and trivial. Kaz _____________________________ Posted through www.DSPRelated.com

0 |

1/15/2015 6:05:07 PM

On Wednesday, January 14, 2015 at 6:43:09 PM UTC-5, kaz wrote: > For FPGAs you can either check the whole value or better just the few MSB > bits to be ddiscarded as follows: > > -- checking one MSB bit and clipping, assuming data1 is 17 bits signed > if data1(16:15) = "00" or data1(16:15) = "11" then > data <= data1(15 downto 0); > elsif data1(16) = '1' then > data <= -32767; > else > data <= +32767; > end if; > > > Kaz > > _____________________________ > Posted through www.DSPRelated.com Shouldn't "assuming data is 17 bits signed" also include that it has not overflowed yet?

0 |

1/17/2015 8:07:51 PM

>On Wednesday, January 14, 2015 at 6:43:09 PM UTC-5, kaz wrote: >> For FPGAs you can either check the whole value or better just the few MSB >> bits to be ddiscarded as follows: >> >> -- checking one MSB bit and clipping, assuming data1 is 17 bits signed >> if data1(16:15) = "00" or data1(16:15) = "11" then >> data <= data1(15 downto 0); >> elsif data1(16) = '1' then >> data <= -32767; >> else >> data <= +32767; >> end if; >> >> >> Kaz >> >> _____________________________ >> Posted through www.DSPRelated.com > >Shouldn't "assuming data is 17 bits signed" also include that it has not overflowed yet? > A final result will be a number of bits(32,32,30,...18,17...) and any discarded msb need be checked and that implies no overflow. Kaz _____________________________ Posted through www.DSPRelated.com

0 |

1/17/2015 8:38:40 PM

Hi, Anybody knows how to create this matrix but without using any loops? a=[1 1 1 1 1 ;2 2 2 2 2 ;3 3 3 3 3 ;.......;n n n n n ] Thank you. Hana. Hana wrote: > Hi, > Anybody knows how to create this matrix but without using any loops? > a=[1 1 1 1 1 ;2 2 2 2 2 ;3 3 3 3 3 ;.......;n n n n n ] HELP REPMAT - Randy Hana wrote: > > > Hi, > Anybody knows how to create this matrix but without using any > loops? > a=[1 1 1 1 1 ;2 2 2 2 2 ;3 3 3 3 3 ;.......;n n n n n ] > > Thank you. > Hana. Hope this isn't homework. >> repmat([1:n]'...

#1 #n+1 #2n+1 #2 #n+2 #2n+2 #3 #n+3 #2n+3 #n #2n #3n #1 #2 #3 #n #n+1 #n+2 #n+3 #2n #2n+1 100 Gbps aggregate stream of 64/66b words virtual lane markers virtual lane 1 virtual lane 2 virtual lane 3 virtual lane n Simple 66-bit word level round robin distribution Transmit PM Transmit PM Receive PM Receive PM Transmit PC Receive PC 1 0.0 1.0 0.1 0.2 0.3 1.2 1.2 1.1 0.0 1.0 0.1 1.1 2.0 3.0 4.0 6.0 7.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 17.0 18.0 19.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 1...

Notation: R(a,k) denotes the rising factorial a(a+1)...(a+k-1 ...the certificate being 2 2 2 (5 m - 12 m p - 2 m + 8 p + 3 n m - n - 4 n p + 1 + 4 p) n -------------------------------------------------------------, QED . ... Musatov ...

in: http://:{(n + 1 )*(n + 2)} - {n (n + 1)} out:: .{-n (1 + n) + (1 + n) (2 + n)} In[1]:= 1*2 Out[1]= 2 In[2]:= 2*3 Out[2]= 6 In[3]:= 6 - 2 In[4]:= 4 - 1 In[5]:= FactorInteger[3] Out[5]= {{3, 1}} In[6]:= 2*3 Out[6]= 6 In[7]:= 3*4 Out[7]= 12 In[8]:= 12 - 6 In[9]:= 6 - 1 Out[9]= 5 In[10]:= 3*4 Out[10]= 12 In[11]:= 4*5 Out[11]= 20 In[12]:= 20 - 12 In[13]:= 8 - 1 In[22]:= FactorInteger[7] Out[22]= {{7, 1}} In[14]:= 4*5 Out[14]= 20 In[15]:= 5*6 Out[15]= 30 In[16]:= 30 - 20 In[63]:= FactorInteger[10] Out[63]= {{2, 1}, {5, 1}} In[18]:= 5*6 Out[18]= 30 In[19]:= 6*7 O...

I have a Conjecture: For every n > 1 there is always at least one prime p such that (n-1)n/2 < p < n(n+1)/2 n = 2; b = 1; While[NextPrime[b] < (b = n (n + 1)/2), n++] n $Aborted 14394105 In this diagram,there is at least one small point(prime) between every two medium points(triangle number ). In[58]:= start = 1; n = 400; pl = Table[{Prime[i], n}, {i, start, n}]; tl = Table[{i (i + 1)/2, n}, {i, start, n}]; ListLinePlot[Prime[Range[start, n]], Epilog -> {PointSize[Medium], Point[tl], PointSize[Small], Point[pl]}] The still unsolved Legendre'...

Is there a way to achieve a vector like the one below without using loops? [0 0 1 1 2 2 3 3 4 4 ... n n] "Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <kp999d$a8e$1@newscl01ah.mathworks.com>... > Is there a way to achieve a vector like the one below without using loops? > > [0 0 1 1 2 2 3 3 4 4 ... n n] You could try this: floor(0:1/rep:n+1-1/rep) where rep is the number of repetitions (2 in your case) Hi, a cool way to do that is using the kronecker product kron(0:n,[1 1]); "Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <...

Subject: Re: SUM { a[i]^2 } / N^2 or SUM { (a[i]/N)^2 } From: Arnold Neumaier <Arnold.Neumaier@univie.ac.at>, University of Vienna Date: Wed, 29 Oct 2003 18:51:31 +0100 .. > spasmous wrote: .. >> SUM { a[i]^2 } / N^2 or SUM { (a[i]/N)^2 } .. >> Is the second way superior for rounding errors or doesn't it make >> any difference? .. > It depends on the bracketing and on the size of the a[i]. .. > SUM { (a[i]/N)^2 } is both 25% faster and 25% less inaccurate > (worst case) than SUM {{ a[i]^2 } / N^2} .. This is not what he asked. The first way is SUM { ...

Hi, I use Simulink FFT block to generate HDL code. The help says: N>8 Tcycle = 3N/2-2 + log2(N)*(N/2+3); I see that it uses 4 multipliers in the butterfly. I would like to know the meaning of the above equation. 3N/2-2 is the prelog? For each cyle, what is the cycle number? It uses 4 DPRAM. I guess that it should have a number account for the DPRAM cycles, some delay register cycles, but I cannot find that number in the above eqaution. Could you help me? Thanks, ...

P=((n*n)-2)*(n*n))-1P Q.E.D. Q.E.D,: n=22 . Then 22*24-1 =527=31*17 where are the 5's and 10's 42*44-1 =1763=41*43 And: 10002*10004-1= 100060007 = 1279.81~78233 Martin Musatov Solved P==NP with this post. ($1MM Clay Millennium Prize to be donated to cure childhood cancer) On Sep 23, 9:19=A0pm, "M.MichaelMusatov" <marty.musa...@gmail.com> wrote: =A0P=3D((n*n)-2)*(n*n))-1P =A0Q.E.D. Q.E.D,: n=3D22 . Then 22*24-1 =3D527=3D31*17 where are the 5's and 10's 42*44-1 =3D1763=3D41*43 And: 10002*10004-1=3D 100060007 =3D 1279.81~78233 Martin Musatov Solved P...

Hello all, I was wondering if calling void wxChoice::SetSelection(int n); in 2.4.2, or void wxControlWithItems::SetSelection(int n); in 2.5.3 with n being -1 is valid in order to get "No Selection". The docs just say that n is the zero-based index, which does not provide any info about how "no selection" can be achieved. Thank you very much in advance, and best regards, Carsten -- Ca3D - Engine http://www.Ca3D-Engine.de Carsten Fuchs http://www.Ca3D-Engine.de/carsten -------------------------------------------------------------...

How to write it in compact form to avoid repetition "shah " <shahkhn3@gmail.com> wrote in message <lodugh$8hr$1@newscl01ah.mathworks.com>... > How to write it in compact form to avoid repetition You'll find in this thread different solutions for similar question http://www.mathworks.fr/matlabcentral/newsreader/view_thread/335814 Bruno ...

Hi, Can anybody tell me the solution for the 3-Sum problem of computational geometry running in O(N^2) time. I have tried to search it on net but i couldn't get it. It would be great if you could even give me a web-link describing the O(N^2) solution. Problem: Given a set S of n integers, are there elements a, b, c in S such that a + b + c = 0? My solution is giving me O(N^2.log(N)) time. My Solution psuedocode: int sum3(int[] S) { sort(S); for(i=1 to S.length-1) for(j=i to S.length) { currentSum=S[i]+S[j]; Use Binary search to search ...

Hi, Can anybody tell me the solution for the 3-Sum problem of computational geometry running in O(N^2) time. I have tried to search it on net but i couldn't get it. It would be great if you could even give me a web-link describing the O(N^2) solution. Problem: Given a set S of n integers, are there elements a, b, c in S such that a + b + c = 0? My solution is giving me O(N^2.log(N)) time. My Solution psuedocode: int sum3(int[] S) { sort(S); for(i=1 to S.length-1) for(j=i to S.length) { currentSum=S[i]+S[j]; Use Binary search to search for num...

Hi, basically, what I'm trying to do is to get the output of ind2sub (or of any function, for that matter) to output a vector and assign it to an existing vector. I know I could assign each element of the output to each element of the existing vector. The problem is when the dimensions of the output are not fixed. What I want to do is to be able to specify an output without MATLAB overwriting it and checking its dimensions. My idea is for this function to work regardless of the dimensions, such as replacing: [ab(1) ab(2) ... ab(N)] = function(...) with [ab(1:N)] = function(...) As an exa...

In digital photography and digital video, clipping is a result of capturing or processing an image where the intensity in a certain area falls ...

Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Get sling Note - Web Clipping the Easy Way on the App Store. See screenshots and ratings, and read customer reviews.

The economy has caused a change in how we shop. Here are a couple of great websites for coupon clipping: www.couponmom.com (free) www.thegrocerygame.com ...

Find the UNCENSORED VERSION on VIMEO https://vimeo.com/97166268 "Body & Blood" from the 6/10/14 clipping. album, CLPPNG order CLPPNG Sub Pop ...

Australian Super chief executive Ian Silk says too many people working in financial services are using the compulsory retirement savings system ...

Whatever shape Qantas finds itself in a year from now, it seems unlikely Alan Joyce will still be running the airline.

Researchers behind the largest cancer study ever in Atlantic Canada have set a world record for the largest toenail collection, and now they're ...

A pilot is in hospital after his plane crashed and burst into flames after hitting a semi-trailer truck while attempting to land on a British ...

OTTAWA - One of Mike Duffy's first cousins in Prince Edward Island was paid after sending him scanned copies of news articles from the local ...

Resources last updated: 1/26/2016 3:32:47 AM