Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
fa09834b
Commit
fa09834b
authored
5 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
add Nyldon factoring algorithm
parent
d4cd6143
No related branches found
No related tags found
1 merge request
!102
Merge jt
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2algo/src/stringology/properties/NyldonFactoring.cpp
+19
-0
19 additions, 0 deletions
alib2algo/src/stringology/properties/NyldonFactoring.cpp
alib2algo/src/stringology/properties/NyldonFactoring.h
+63
-0
63 additions, 0 deletions
alib2algo/src/stringology/properties/NyldonFactoring.h
with
82 additions
and
0 deletions
alib2algo/src/stringology/properties/NyldonFactoring.cpp
0 → 100644
+
19
−
0
View file @
fa09834b
/*
*
NyldonFactoring
.
cpp
*
*
Created
on
:
30.
8.
2018
*
Author
:
Jan
Travnicek
*/
#include
"NyldonFactoring.h"
#include
<registration/AlgoRegistration.hpp>
namespace
{
auto
nyldonFactoringString
=
registration
::
AbstractRegister
<
stringology
::
properties
::
NyldonFactoring
,
ext
::
vector
<
unsigned
>
,
const
string
::
LinearString
<
>
&
>
(
stringology
::
properties
::
NyldonFactoring
::
factorize
).
setDocumentation
(
"Computes the nyldon factoring of a given nonempty string
\n
\
\
n
\
@
param
string
the
nonempty
string
to
factorize
\
n
\
@
return
positions
where
the
string
is
split
to
nyldon
factors
" );
}
/* namespace */
This diff is collapsed.
Click to expand it.
alib2algo/src/stringology/properties/NyldonFactoring.h
0 → 100644
+
63
−
0
View file @
fa09834b
/*
* NyldonFactoring.h
*
* Created on: 29. 8. 2019
* Author: Jan Travnicek
*
* Based on code from arXiv:1804.09735
*/
#ifndef NYLDON_FACTORING_H_
#define NYLDON_FACTORING_H_
#include <string/LinearString.h>
#include <alib/deque>
namespace stringology {
namespace properties {
class NyldonFactoring {
public:
/**
* Computes the nyldon factoring of a given nonempty string.
*
* @param string the nonempty string to factorize
* @return positions where the string is split to nyldon factors
*/
template < class SymbolType >
static ext::vector < unsigned > factorize ( const string::LinearString < SymbolType > & string );
};
template < class SymbolType >
ext::vector < unsigned > NyldonFactoring::factorize ( const string::LinearString < SymbolType > & string ) {
unsigned n = string.getContent ( ).size ( );
ext::deque < ext::vector < SymbolType > > NyIF { ext::vector < SymbolType > { string.getContent ( ) [ n - 1 ] } };
for ( unsigned i = 2; i <= n; ++ i ) {
NyIF.push_front ( ext::vector < SymbolType > { string.getContent ( ) [ n - i ] } );
while ( NyIF.size ( ) >= 2 && NyIF [ 0 ] > NyIF [ 1 ] ) {
ext::vector < SymbolType > tmp = std::move ( NyIF [ 0 ] );
tmp.insert ( tmp.end ( ), NyIF [ 1 ].begin ( ), NyIF [ 1 ].end ( ) );
NyIF.pop_front ( );
NyIF.pop_front ( );
NyIF.push_front ( std::move ( tmp ) );
}
}
ext::vector < unsigned > factorization;
unsigned i = 0;
for ( const ext::vector < SymbolType > factor : NyIF ) {
factorization.push_back ( i );
i += factor.size ( );
}
return factorization;
}
} /* namespace properties */
} /* namespace stringology */
#endif /* NYLDON_FACTORING_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment