#ifndef _MDS_h_
#define _MDS_h_
/* MDS.h
*
* Multi Dimensional Scaling
*
* Copyright (C) 1993-2020, 2026 David Weenink, 2015,2017,2018 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This code is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this work. If not, see .
*/
/*
djmw 20020813 GPL header
djmw 20110306 Latest modification.
*/
#include "Covariance.h"
#include "Correlation.h"
#include "Graphics.h"
#include "Minimizers.h"
#include "Confusion.h"
#include "ContingencyTable.h"
#include "MDSVec.h"
#include "TableOfReal_extensions.h"
#include "Proximity.h"
#include "Distance.h"
#include "Configuration.h"
#include "MDS_enums.h"
/************************** class Weight **************************************/
Thing_define (Weight, TableOfReal) {
};
autoWeight Weight_create (integer numberOfPoints);
/************************** class Salience **************************************/
Thing_define (Salience, TableOfReal) {
};
autoSalience Salience_create (integer numberOfSources, integer numberOfDimensions);
void Salience_setDefaults (Salience me);
integer Salience_correctNegatives (Salience me);
void Salience_draw (Salience me, Graphics g, integer xdimension, integer ydimension, bool garnish);
autoConfiguration ContingencyTable_to_Configuration_ca (ContingencyTable me, integer numberOfDimensions, integer scaling);
#pragma mark - class ConfusionList
Collection_define (ConfusionList, OrderedOf, Confusion) {
TableOfRealList asTableOfRealList () {
return reinterpret_cast (this);
}
};
autoConfusion ConfusionList_sum (ConfusionList me);
#pragma mark - class ScalarProduct
Thing_define (ScalarProduct, TableOfReal) {
};
autoScalarProduct ScalarProduct_create (integer numberOfPoints);
#pragma mark - class ScalarProductList
Collection_define (ScalarProductList, OrderedOf, ScalarProduct) {
TableOfRealList asTableOfRealList () {
return reinterpret_cast (this);
}
};
#pragma mark - class Dissimilarity
#pragma mark - class Transformator
Thing_define (Transformator, Thing) {
integer numberOfPoints;
integer normalization;
virtual autoDistance v_transform (MDSVec vec, Distance dist, Weight w);
};
void Transformator_init (Transformator me, integer numberOfPoints);
autoTransformator Transformator_create (integer numberOfPoints);
void Transformator_setNormalization (Transformator me, integer normalization);
autoDistance Transformator_transform (Transformator me, MDSVec vec, Distance dist, Weight w);
Thing_define (ISplineTransformator, Transformator) {
integer numberOfInteriorKnots, order, numberOfParameters;
autoMAT m;
autoVEC b, knot;
autoDistance v_transform (MDSVec vec, Distance dist, Weight w)
override;
};
autoISplineTransformator ISplineTransformator_create (integer numberOfPoints, integer numberOfInteriorKnots, integer order);
Thing_define (RatioTransformator, Transformator) {
double ratio;
autoDistance v_transform (MDSVec vec, Distance dist, Weight w)
override;
};
autoRatioTransformator RatioTransformator_create (integer numberOfPoints);
Thing_define (MonotoneTransformator, Transformator) {
kMDS_TiesHandling tiesHandling;
autoDistance v_transform (MDSVec vec, Distance dist, Weight w)
override;
};
autoMonotoneTransformator MonotoneTransformator_create (integer numberPoints);
void MonotoneTransformator_setTiesProcessing (MonotoneTransformator, kMDS_TiesHandling tiesHandling);
/************** Kruskal *********************************************/
Thing_define (Kruskal, Thing) {
autoConfiguration configuration;
autoProximityList proximities;
kMDS_TiesHandling tiesHandling;
kMDS_KruskalStress stress_formula;
autoMDSVec vec;
autoMAT dx;
autoMinimizer minimizer;
};
autoKruskal Kruskal_create (integer numberOfPoints, integer numberOfDimensions);
autoConfiguration Dissimilarity_to_Configuration_kruskal (Dissimilarity me,
integer numberOfDimensions, integer metric, kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula,
double tolerance, integer numberOfIterations, integer numberOfRepetitions);
autoConfiguration Dissimilarity_Configuration_kruskal (Dissimilarity me, Configuration him,
kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula,
double tolerance, integer numberOfIterations, integer numberOfRepetitions);
double Dissimilarity_Configuration_getStress (Dissimilarity me, Configuration him, kMDS_TiesHandling tiesHandling, kMDS_KruskalStress stress_formula);
/******** end Kruskal **************************************************/
double Dissimilarity_Configuration_Weight_Transformator_normalizedStress (Dissimilarity me, Configuration conf, Weight weight, Transformator t);
double Distance_Weight_stress (Distance fit, Distance c, Weight w, kMDS_stressMeasure type);
/*
Calculates stress.
type is one of (MDS_NORMALIZED_STRESS, MDS_STRESS_1,
MDS_STRESS_2, MDS_RAW_STRESS)
*/
double Distance_Weight_congruenceCoefficient (Distance x, Distance y, Weight w);
/*
Congruence coefficient B&G page 350.
*/
void Distance_Weight_rawStressComponents (Distance fit, Distance conf, Weight weight, double *out_eta_fit, double *out_eta_conf, double *out_rho);
/*
Computes
eta_fit = sum (i