Comments (4)
The situation is more complicated indeed than for in
and cm
. I need to ponder your proposal there is something I don't see, but it is too late here, I must sleep.
edit: you can skip most of my chatter here and jump to last line
As I did not see an obvious analytical way, I see a dumber way: very few dimensions are not expressible in bp
, only 3
out of very chunk of 803
. So start from \texdimenmmdown{N sp}
or rather get from its internals the integera
such that M = floor(a*7227/2540)
is largest one smaller than N
. We have 800 chances out of 803 that it will be exactly expressible in bp
unit, which we can check by testing M
modulo 803
(I must sleep so I don't search now the 3 gaps, maybe they are in your comment). If we are unlucky, replace a
by a-1
and check again. In at most 4 steps (here I would need to know the gaps to tell better) we can not have been unlucky systematically (maybe only two steps) because decreasing a
by 1
will only decrease M
by 2
or 3
and we can not hit 4 gaps in such a short stretch which are all distinct modulo 803
. Now probably it is much better still because the gaps are probably at 803/3 distance from one another... oh well let's get them
>>> S=set((n*803)//800 for n in range(800));
>>> T=set(n for n in range(803));
>>> print(T-S);
{802, 267, 535}
so no it's trivial: we only have to do a->a-1
once. Either it works for a
or it will work for a-1
.
So for algorithm it looks easy, but analytically with a formula like the one for both in and cm ... looks indeed more difficult, but this another matter.
Thanks as clearly I need to add this and I will tomorrow.
from texdimens.
aside: again I was not notified of issue creation; I am notified of comments on already created issues but not of issue creations... I saw this one yesterday because I came to the web interface
Yesterday was too tired and did not read your post carefully after this paragraph:
The situation is different (and far more complicated) for
bp
andmm
though. I started by looking at inputs inmm
unit, soX=floor(a*7227/2540)
for somea=2540*k+r
(r=0..2539
). Since the behavior ofX
is periodic (mod 2540), we can focus ona=0..2539
only. Now the question is whether thisX
is attainable frombp
or not.
You are right but expressed yourself at a too high level for a dummy like myself. For some reason, when I read that first I had not noticed that 7227=9*803
. We want X = floor(a*7227/2540)
to be also floor(b*803/800)
, i.e. X=floor(b*7227/7200)
. Out the 7227
congruence classes of X
modulo 7227
this excludes 27
of them, which as stated in your post are those 27
which modulo 803
are in {267,535,802}
. Now the first formula authorizes only 2540
, i.e. about one third of all possible classes modulo 7227
, and we are axcluding now 27
in total so we expect about 9
will have to be excluded from the 2540
possible values of floor(a*7227/2540)
. This you obtained by brute force, examining, actually, each of the three exclusion condition modulo 803
one at a turn.
So I agree with your analysis, but it looks a priori an overhead to check for a
modulo 2540
and exclude there 9
values. It looks simpler once we have both X
and a
to apply the test on X mod. 803
that it has to be distinct from {267,535,802}
. If it is not distinct we replace a
by a-1
and X
by a new one which will be either X-2
or X-3
.
For implementation I must think: we can go brute force with existing macros, i.e., use first \texdimenmmdown
then check if the obtained distance dimension remain invariant under \texdimenbp
, if yes we are done, if not we know we must decrease by 1
the a
(which verifies a sp = D pt
where D = \texdimenmmdown{input}
, but we will have hijacked the latter macro which actually computes a
first).
As per complete math analytically, we are in a situation where we allow now only 2540-9=2531
values of X
modulo 7227
. But a priori the allowed X
will not be those of the shape floor(k 7227/2531)
... I have not checked, I admit a priori I can not believe such a thing will work. And any formula of the type X = floor(k G)
where G
is a reduced fraction A/B > 1
allows to recover G
if we know the values of X
for k=0..(B-1)
simply by counting them. Time to break out before I err with too approximative things.
from texdimens.
1. get `a`; 2. test if `a=94`, `282`, `1035`, `1223`, `1317`, `1411`, `1505`, `1693`, or `2446` (mod 2540). 3. if not, leave `a` as is. 4. if yes, `a := a-1`.
I am going probably to do the following:
- get
a
andX
(from\texdimenmmdown
innards) - test if
X=267
,535
,802
modulo803
, i.e. ifX sp
is attainable bybp
[or replacedo this byany competitor to check ifsimply useX sp
is attainable bybp
, perhapstexdimenbp
innards) - if not, leave
a
as is. - if yes
a := a-1
.
This scheme would be for a \texdimenbothbpmm
whose output will be for mm
. It seems for output in bp
we need to add a fifth step which is
- ... and get the new
X
then obtain the result inbp
unit from\texdimenbp
or its innards.
from texdimens.
This was closed in 7795ab0 (#11)
from texdimens.
Related Issues (15)
- Rename all macros to use \texdimen prefix? HOT 1
- Cover negative dimen2 in `\texdimenwithunit` HOT 21
- \texdimenwithunit{dim1}{dim2} could and even should output a ratio R closer to mathematical dim1/dim2
- Let the `\texdimenUU{up,down}` be usable even with `\maxdimen` input also for the `dd`, `nc` and `in` units
- Add a CHANGES.md file
- About `ex` and `em` units HOT 8
- Please make explicit mysterious "I considered various ways" code comments to \texdimenwithunit
- Code comment of `\texdimenwithunit` about some `E` possibly `1.0`, not always `0.ddd...` seems wrong HOT 3
- Why isn't "TeX" rendered with a stylish (sort-of) epsilon letter (nicely shifted downwards) in the pdf documentation? HOT 1
- Documentation in 1.1 release of \texdimenbothbpmm and \texdimenbothmmbp use "smaller than" but intend "not exceeding"
- \texdimenwithunit{0pt}{<dim>} should always output 0.0 but it does not
- \texdimenwithunit{0pt}{1pt} plain wrong
- 0.99b still does not get \texdimenwithunit{dim1}{1pt} right... HOT 3
- \texdimenwithunit{dim}{1pt} as "fixed" for #4 and #6 can cause overflow!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from texdimens.